Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=6b45d6da11d90f5d8bb8f3aae5bce8a31a5e42cb
commit 6b45d6da11d90f5d8bb8f3aae5bce8a31a5e42cb Author: Michel Hermier <[email protected]> Date: Sat Aug 2 08:43:54 2014 +0200 libpacman: Only use GMT function when using MDTM format. diff --git a/lib/libpacman/io/ftp.c b/lib/libpacman/io/ftp.c index 2845fc7..07e38f4 100644 --- a/lib/libpacman/io/ftp.c +++ b/lib/libpacman/io/ftp.c @@ -32,7 +32,7 @@ size_t _pacman_ftp_strfmdtm(char *s, size_t max, const time_t *time) { - return strftime(s, max, PM_FTP_MDTM_FORMAT, time != NULL ? gmtime(time) : f_localtime(NULL)); + return strftime(s, max, PM_FTP_MDTM_FORMAT, f_gmtime(time)); } char *_pacman_ftp_strpmdtm(const char *s, time_t *time) @@ -45,7 +45,7 @@ char *_pacman_ftp_strpmdtm(const char *s, time_t *time) if((ret = strptime(s, PM_FTP_MDTM_FORMAT, &ptimestamp)) != NULL) { time_t tmp; - if((tmp = mktime(&ptimestamp)) != PM_TIME_INVALID) { + if((tmp = timegm(&ptimestamp)) != PM_TIME_INVALID) { *time = tmp; } else { ret = NULL; diff --git a/lib/libpacman/util/time.c b/lib/libpacman/util/time.c index ad9b056..70c3dfe 100644 --- a/lib/libpacman/util/time.c +++ b/lib/libpacman/util/time.c @@ -46,6 +46,17 @@ locale_t f_locale_c(void) return locale_c; } +struct tm *f_gmtime(const time_t *timep) +{ + time_t now; + + if(timep == NULL && + (now = time(NULL)) != PM_TIME_INVALID) { + timep = &now; + } + return gmtime(timep); +} + struct tm *f_localtime(const time_t *timep) { time_t now; diff --git a/lib/libpacman/util/time.h b/lib/libpacman/util/time.h index 8418407..df67191 100644 --- a/lib/libpacman/util/time.h +++ b/lib/libpacman/util/time.h @@ -32,6 +32,10 @@ double f_difftimeval(struct timeval timeval1, struct timeval timeval2) ((double)(timeval1.tv_usec - timeval2.tv_usec) / 1000000); } +/* Return the gmtime for timep. If timep is NULL, return the conversion for time(NULL) (libc returns NULL instead). + */ +struct tm *f_gmtime(const time_t *timep); + /* Return the localtime for timep. If timep is NULL, return the conversion for time(NULL) (libc returns NULL instead). */ struct tm *f_localtime(const time_t *timep); _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
