Mercurial > hg > octave-terminal
changeset 11328:f286a874617c
datestr: handle dates before 1970-01-01
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 09 Dec 2010 02:37:21 -0500 |
parents | ef0e995f8c0f |
children | 6b073da9d7fc |
files | scripts/ChangeLog scripts/time/datestr.m |
diffstat | 2 files changed, 15 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2010-12-09 John W. Eaton <jwe@octave.org> + + * time/datestr.m: Don't call localtime (mktime (tm)) to fill in + missing elements of time strcture. + 2010-12-08 Ben Abbott <bpabbott@mac.com> * plot/fill.m: Fix bug that implies nextplot = "add".
--- a/scripts/time/datestr.m +++ b/scripts/time/datestr.m @@ -247,7 +247,8 @@ df = regexprep (df, '[Dd][Dd]', "%d"); - tmp = names_d{weekday (datenum (v(i,1), v(i,2), v(i,3)))}; + wday = weekday (datenum (v(i,1), v(i,2), v(i,3))); + tmp = names_d{wday}; df = regexprep (df, '([^%])[Dd]', sprintf ("$1%s", tmp)); df = regexprep (df, '^[Dd]', sprintf ("%s", tmp)); @@ -277,10 +278,14 @@ sec = vi(6); tm.sec = fix (sec); tm.usec = fix (rem (sec, 1) * 1e6); - ## Force mktime to check for DST. - tm.isdst = -1; - - str = strftime (df, localtime (mktime (tm))); + tm.wday = wday - 1; + ## FIXME -- Do we need YDAY and DST? How should they be computed? + ## We don't want to use "localtime (mktime (tm))" because that + ## doesn't correctly handle dates before 1970-01-01 on some systems. + ## tm.yday = ?; + ## tm.isdst = ?; + + str = strftime (df, tm); if (i == 1) retval = str;