Mercurial > hg > octave-lyh
changeset 1374:674a17e1dbab
[project @ 1995-09-11 23:43:20 by jwe]
author | jwe |
---|---|
date | Mon, 11 Sep 1995 23:44:10 +0000 |
parents | cea4101a2f18 |
children | 6ff3b87196fb |
files | scripts/time/clock.m src/timefns.cc |
diffstat | 2 files changed, 44 insertions(+), 44 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/time/clock.m +++ b/scripts/time/clock.m @@ -28,11 +28,11 @@ retval = zeros (1, 6); - retval(1) = tm.tm_year + 1900; - retval(2) = tm.tm_mon + 1; - retval(3) = tm.tm_mday; - retval(4) = tm.tm_hour; - retval(5) = tm.tm_min; - retval(6) = tm.tm_sec + tm.tm_usec / 1e6; + retval(1) = tm.year + 1900; + retval(2) = tm.mon + 1; + retval(3) = tm.mday; + retval(4) = tm.hour; + retval(5) = tm.min; + retval(6) = tm.sec + tm.usec / 1e6; endfunction
--- a/src/timefns.cc +++ b/src/timefns.cc @@ -36,29 +36,29 @@ // Date and time functions. static Octave_map -mk_tm_map (struct tm *tm, double fraction) +mk_tm_map (struct tm& tm, double fraction) { Octave_map m; - m ["tm_usec"] = fraction * 1e6; - m ["tm_sec"] = (double) tm->tm_sec; - m ["tm_min"] = (double) tm->tm_min; - m ["tm_hour"] = (double) tm->tm_hour; - m ["tm_mday"] = (double) tm->tm_mday; - m ["tm_mon"] = (double) tm->tm_mon; - m ["tm_year"] = (double) tm->tm_year; - m ["tm_wday"] = (double) tm->tm_wday; - m ["tm_yday"] = (double) tm->tm_yday; - m ["tm_isdst"] = (double) tm->tm_isdst; + m ["usec"] = fraction * 1e6; + m ["sec"] = (double) tm.tm_sec; + m ["min"] = (double) tm.tm_min; + m ["hour"] = (double) tm.tm_hour; + m ["mday"] = (double) tm.tm_mday; + m ["mon"] = (double) tm.tm_mon; + m ["year"] = (double) tm.tm_year; + m ["wday"] = (double) tm.tm_wday; + m ["yday"] = (double) tm.tm_yday; + m ["isdst"] = (double) tm.tm_isdst; #if defined (HAVE_TM_ZONE) - m ["tm_zone"] = tm->tm_zone; + m ["zone"] = tm.tm_zone; #elif defined (HAVE_TZNAME) - if (tm->tm_isdst && tzname[1] && *tzname[1]) - m ["tm_zone"] = tzname[1]; + if (tm.tm_isdst && tzname[1] && *tzname[1]) + m ["zone"] = tzname[1]; else - m ["tm_zone"] = tzname[0]; + m ["zone"] = tzname[0]; #else - m ["tm_zone"] = zone_name (tm); + m ["zone"] = zone_name (tm); #endif return m; @@ -69,18 +69,18 @@ { static struct tm tm; - fraction = (m ["tm_usec"] . double_value ()) / 1e6; - tm.tm_sec = NINT (m ["tm_sec"] . double_value ()); - tm.tm_min = NINT (m ["tm_min"] . double_value ()); - tm.tm_hour = NINT (m ["tm_hour"] . double_value ()); - tm.tm_mday = NINT (m ["tm_mday"] . double_value ()); - tm.tm_mon = NINT (m ["tm_mon"] . double_value ()); - tm.tm_year = NINT (m ["tm_year"] . double_value ()); - tm.tm_wday = NINT (m ["tm_wday"] . double_value ()); - tm.tm_yday = NINT (m ["tm_yday"] . double_value ()); - tm.tm_isdst = NINT (m ["tm_isdst"] . double_value ()); + fraction = (m ["usec"] . double_value ()) / 1e6; + tm.tm_sec = NINT (m ["sec"] . double_value ()); + tm.tm_min = NINT (m ["min"] . double_value ()); + tm.tm_hour = NINT (m ["hour"] . double_value ()); + tm.tm_mday = NINT (m ["mday"] . double_value ()); + tm.tm_mon = NINT (m ["mon"] . double_value ()); + tm.tm_year = NINT (m ["year"] . double_value ()); + tm.tm_wday = NINT (m ["wday"] . double_value ()); + tm.tm_yday = NINT (m ["yday"] . double_value ()); + tm.tm_isdst = NINT (m ["isdst"] . double_value ()); #ifdef HAVE_TMZONE - tm.tm_zone = (m ["tm_zone"] . string_value ()); + tm.tm_zone = (m ["zone"] . string_value ()); #endif return &tm; @@ -152,17 +152,17 @@ Given a value returned from time(), return a structure with\n\ the following elements:\n\ \n\ - tm_usec : microseconds after the second (0, 999999)\n\ - tm_sec : seconds after the minute (0, 61)\n\ - tm_min : minutes after the hour (0, 59)\n\ - tm_hour : hours since midnight (0, 23)\n\ - tm_mday : day of the month (1, 31)\n\ - tm_mon : months since January (0, 11)\n\ - tm_year : years since 1900\n\ - tm_wday : days since Sunday (0, 6)\n\ - tm_yday : days since January 1 (0, 365)\n\ - tm_isdst : Daylight Savings Time flag\n\ - tm_zone : Time zone") + usec : microseconds after the second (0, 999999)\n\ + sec : seconds after the minute (0, 61)\n\ + min : minutes after the hour (0, 59)\n\ + hour : hours since midnight (0, 23)\n\ + mday : day of the month (1, 31)\n\ + mon : months since January (0, 11)\n\ + year : years since 1900\n\ + wday : days since Sunday (0, 6)\n\ + yday : days since January 1 (0, 365)\n\ + isdst : Daylight Savings Time flag\n\ + zone : Time zone") { Octave_object retval;