1 /* PO/POT file timestamps.
2 Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc.
3 Written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, April 1995.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
29 #define TM_YEAR_ORIGIN 1900
31 /* Yield A - B, measured in seconds. */
33 difftm (const struct tm
*a
, const struct tm
*b
)
35 int ay
= a
->tm_year
+ TM_YEAR_ORIGIN
- 1;
36 int by
= b
->tm_year
+ TM_YEAR_ORIGIN
- 1;
37 /* Some compilers cannot handle this as a single return statement. */
39 /* difference in day of year */
40 a
->tm_yday
- b
->tm_yday
41 /* + intervening leap days */
42 + ((ay
>> 2) - (by
>> 2))
43 - (ay
/ 100 - by
/ 100)
44 + ((ay
/ 100 >> 2) - (by
/ 100 >> 2))
45 /* + difference in years * 365 */
46 + (long) (ay
- by
) * 365l);
48 return 60l * (60l * (24l * days
+ (a
->tm_hour
- b
->tm_hour
))
49 + (a
->tm_min
- b
->tm_min
))
50 + (a
->tm_sec
- b
->tm_sec
);
55 po_strftime (const time_t *tp
)
61 local_time
= *localtime (tp
);
63 tz_min
= difftm (&local_time
, gmtime (tp
)) / 60;
69 return xasprintf ("%d-%02d-%02d %02d:%02d%c%02ld%02ld",
70 local_time
.tm_year
+ TM_YEAR_ORIGIN
,
71 local_time
.tm_mon
+ 1,
75 tz_sign
, tz_min
/ 60, tz_min
% 60);