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:
Richard Frith-MacDonald 2006-03-08 11:48:25 +00:00
parent c2e8c881e7
commit 519e1dca8f
2 changed files with 18 additions and 10 deletions

View file

@ -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