diff --git a/ChangeLog b/ChangeLog index 60cea1063..7e3afe3a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ required. * Source/win32/NSStreamWin32.m: Use fileSystemRepresentation rather than cStringUsingEncoding: + * Source/NSCalendarDate.m: Support '%T' and '%t' in description. * Source/NSSocketPortNameServer.m: * Source/NSBundle.m: * Source/NSProcessInfo.m: diff --git a/Source/NSCalendarDate.m b/Source/NSCalendarDate.m index 6c65e68b8..952eb1020 100644 --- a/Source/NSCalendarDate.m +++ b/Source/NSCalendarDate.m @@ -174,17 +174,15 @@ lastDayOfGregorianMonth(int month, int year) static inline int absoluteGregorianDay(int day, int month, int year) { - int m, N; - - N = day; // day of month - for (m = month - 1; m > 0; m--) // days in prior months this year - N = N + lastDayOfGregorianMonth(m, year); + while (--month > 0) + day = day + lastDayOfGregorianMonth(month, year); + year--; return - (N // days this year - + 365 * (year - 1) // days in previous years ignoring leap days - + (year - 1)/4 // Julian leap days before this year... - - (year - 1)/100 // ...minus prior century years... - + (year - 1)/400); // ...plus prior years divisible by 400 + (day // days this year + + 365 * year // days in previous years ignoring leap days + + year/4 // Julian leap days before this year... + - year/100 // ...minus prior century years... + + year/400); // ...plus prior years divisible by 400 } /* 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]; 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': [self _format: [locale objectForKey: NSTimeFormatString] locale: locale