From 2dbceb9f8ae57a5882804debfedeaa618407ecba Mon Sep 17 00:00:00 2001 From: Philip Gladstone Date: Fri, 14 Jun 2002 03:38:00 +0000 Subject: [PATCH] Change the way that the ?date= stuff is parsed. It now takes a time (with optional date) in local time rather than GMT. Note that you are advised to use the date as well as the time as the time is relative to the current day (which is not much use if the time is in the future). The date format parsing is pretty strict still: YYYY-MM-DDTHH:MM:SS is a format that works. The T is a literal non-digit character. I wouldn't use a space. The :SS can be omitted. The number of digits *must* be four in the Year. Originally committed as revision 691 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libav/utils.c | 66 +++++++++++++++++++++++++++-------------------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/libav/utils.c b/libav/utils.c index 1de22c0..a314ec4 100644 --- a/libav/utils.c +++ b/libav/utils.c @@ -880,55 +880,45 @@ INT64 parse_date(const char *datestr, int duration) { const char *p; INT64 t; - int sec; + struct tm dt; + + memset(&dt, 0, sizeof(dt)); p = datestr; if (!duration) { - static const UINT8 months[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - int year, month, day, i; - if (strlen(p) >= 5 && p[4] == '-') { - - year = strtol(p, (char **)&p, 10); + dt.tm_year = strtol(p, (char **)&p, 10); if (*p) p++; - month = strtol(p, (char **)&p, 10) - 1; + dt.tm_mon = strtol(p, (char **)&p, 10) - 1; if (*p) p++; - day = strtol(p, (char **)&p, 10) - 1; + dt.tm_mday = strtol(p, (char **)&p, 10) - 1; if (*p) p++; - day += (year - 1970) * 365; - /* if >= March, take February of current year into account too */ - if (month >= 2) - year++; - for(i=1970;i