mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Support '%T' and '%t' in description of a date
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22619 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c2e8c881e7
commit
519e1dca8f
2 changed files with 18 additions and 10 deletions
|
@ -4,6 +4,7 @@
|
||||||
required.
|
required.
|
||||||
* Source/win32/NSStreamWin32.m: Use fileSystemRepresentation rather
|
* Source/win32/NSStreamWin32.m: Use fileSystemRepresentation rather
|
||||||
than cStringUsingEncoding:
|
than cStringUsingEncoding:
|
||||||
|
* Source/NSCalendarDate.m: Support '%T' and '%t' in description.
|
||||||
* Source/NSSocketPortNameServer.m:
|
* Source/NSSocketPortNameServer.m:
|
||||||
* Source/NSBundle.m:
|
* Source/NSBundle.m:
|
||||||
* Source/NSProcessInfo.m:
|
* Source/NSProcessInfo.m:
|
||||||
|
|
|
@ -174,17 +174,15 @@ lastDayOfGregorianMonth(int month, int year)
|
||||||
static inline int
|
static inline int
|
||||||
absoluteGregorianDay(int day, int month, int year)
|
absoluteGregorianDay(int day, int month, int year)
|
||||||
{
|
{
|
||||||
int m, N;
|
while (--month > 0)
|
||||||
|
day = day + lastDayOfGregorianMonth(month, year);
|
||||||
N = day; // day of month
|
year--;
|
||||||
for (m = month - 1; m > 0; m--) // days in prior months this year
|
|
||||||
N = N + lastDayOfGregorianMonth(m, year);
|
|
||||||
return
|
return
|
||||||
(N // days this year
|
(day // days this year
|
||||||
+ 365 * (year - 1) // days in previous years ignoring leap days
|
+ 365 * year // days in previous years ignoring leap days
|
||||||
+ (year - 1)/4 // Julian leap days before this year...
|
+ year/4 // Julian leap days before this year...
|
||||||
- (year - 1)/100 // ...minus prior century years...
|
- year/100 // ...minus prior century years...
|
||||||
+ (year - 1)/400); // ...plus prior years divisible by 400
|
+ year/400); // ...plus prior years divisible by 400
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Should be static, but temporarily changed to non-static until
|
/* Should be static, but temporarily changed to non-static until
|
||||||
|
@ -1730,6 +1728,15 @@ static void Grow(DescriptionInfo *info, unsigned size)
|
||||||
[self _format: @"%I:%M:%S %p" locale: locale info: info];
|
[self _format: @"%I:%M:%S %p" locale: locale info: info];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'T':
|
||||||
|
[self _format: @"%H:%M:S" locale: locale info: info];
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 't':
|
||||||
|
Grow(info, 1);
|
||||||
|
info->t[info->offset++] = '\t';
|
||||||
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
[self _format: [locale objectForKey: NSTimeFormatString]
|
[self _format: [locale objectForKey: NSTimeFormatString]
|
||||||
locale: locale
|
locale: locale
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue