mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
Implemented proper time zone handling when sorting entries
SVN revision: 1539
This commit is contained in:
parent
5fee4630a9
commit
858a5153e9
21
src/elogd.c
21
src/elogd.c
@ -2981,7 +2981,8 @@ char *month_name(int m)
|
|||||||
time_t date_to_ltime(char *date)
|
time_t date_to_ltime(char *date)
|
||||||
{
|
{
|
||||||
struct tm tms;
|
struct tm tms;
|
||||||
int i;
|
int i, date_zone, local_zone;
|
||||||
|
time_t ltime;
|
||||||
|
|
||||||
memset(&tms, 0, sizeof(struct tm));
|
memset(&tms, 0, sizeof(struct tm));
|
||||||
|
|
||||||
@ -3002,6 +3003,20 @@ time_t date_to_ltime(char *date)
|
|||||||
|
|
||||||
if (tms.tm_year < 90)
|
if (tms.tm_year < 90)
|
||||||
tms.tm_year += 100;
|
tms.tm_year += 100;
|
||||||
|
|
||||||
|
ltime = mktime(&tms);
|
||||||
|
|
||||||
|
/* correct for difference between local time zone (used by mktime) and time zone of date */
|
||||||
|
date_zone = atoi(date+26);
|
||||||
|
date_zone = (abs(date_zone) % 100)*60 + (date_zone)/100*3600;
|
||||||
|
|
||||||
|
tzset();
|
||||||
|
local_zone = timezone;
|
||||||
|
if (tms.tm_isdst)
|
||||||
|
local_zone -= 3600;
|
||||||
|
|
||||||
|
ltime = ltime - local_zone - date_zone;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* ctime() complient date */
|
/* ctime() complient date */
|
||||||
@ -3019,9 +3034,11 @@ time_t date_to_ltime(char *date)
|
|||||||
|
|
||||||
if (tms.tm_year < 90)
|
if (tms.tm_year < 90)
|
||||||
tms.tm_year += 100;
|
tms.tm_year += 100;
|
||||||
|
|
||||||
|
ltime = mktime(&tms);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mktime(&tms);
|
return ltime;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user