changeset 20410:31f89b12aaf7

strftime: Add support for "%z" conversion specifier (bug #45592) * oct-time.cc (octave_time::octave_time, octave_base_tm::strftime, octave_base_tm::init, octave_strptime::init): Use HAVE_TM_GMTOFF instead of HAVE_STRUCT_TM_GMTOFF. * time.cc (mk_tm_map, extract_tm): Support "gmtoff" field. (Fgmtime, Flocaltime): Update docstrings to mention "gmtoff". (Fstrftime): Describe the "%z" conversion specifier in docstring. * system.txi (Timing Utilities): Mention "gmtoff" structure element.
author Mike Miller <mtmiller@octave.org>
date Wed, 22 Jul 2015 20:27:11 -0400
parents 0cefba1a1030
children e2feb806332a
files doc/interpreter/system.txi libinterp/corefcn/time.cc liboctave/system/oct-time.cc
diffstat 3 files changed, 15 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/system.txi	Wed Jul 22 09:46:42 2015 -0700
+++ b/doc/interpreter/system.txi	Wed Jul 22 20:27:11 2015 -0400
@@ -80,6 +80,9 @@
 @item isdst
 Daylight Savings Time flag.
 
+@item gmtoff
+Seconds offset from UTC.
+
 @item zone
 Time zone.
 @end table
--- a/libinterp/corefcn/time.cc	Wed Jul 22 09:46:42 2015 -0700
+++ b/libinterp/corefcn/time.cc	Wed Jul 22 20:27:11 2015 -0400
@@ -50,6 +50,7 @@
   m.assign ("wday", static_cast<double> (t.wday ()));
   m.assign ("yday", static_cast<double> (t.yday ()));
   m.assign ("isdst", static_cast<double> (t.isdst ()));
+  m.assign ("gmtoff", static_cast<double> (t.gmtoff ()));
   m.assign ("zone", t.zone ());
 
   return m;
@@ -96,6 +97,7 @@
   tm.wday (intfield (m, "wday"));
   tm.yday (intfield (m, "yday"));
   tm.isdst (intfield (m, "isdst"));
+  tm.gmtoff (intfield (m, "gmtoff"));
   tm.zone (stringfield (m, "zone"));
 
   return tm;
@@ -150,7 +152,8 @@
            wday = 1\n\
            yday = 47\n\
            isdst = 0\n\
-           zone = CST\n\
+           gmtoff = 0\n\
+           zone = GMT\n\
         @}\n\
 @end group\n\
 @end example\n\
@@ -211,6 +214,7 @@
            wday = 1\n\
            yday = 47\n\
            isdst = 0\n\
+           gmtoff = -21600\n\
            zone = CST\n\
         @}\n\
 @end group\n\
@@ -399,6 +403,9 @@
 @item %X\n\
 Locale's time representation (%H:%M:%S).\n\
 \n\
+@item %z\n\
+Offset from UTC (±hhmm), or nothing if no time zone is determinable.\n\
+\n\
 @item %Z\n\
 Time zone (EDT), or nothing if no time zone is determinable.\n\
 @end table\n\
--- a/liboctave/system/oct-time.cc	Wed Jul 22 09:46:42 2015 -0700
+++ b/liboctave/system/oct-time.cc	Wed Jul 22 20:27:11 2015 -0400
@@ -55,7 +55,7 @@
   t.tm_yday = tm.yday ();
   t.tm_isdst = tm.isdst ();
 
-#if defined (HAVE_STRUCT_TM_GMTOFF)
+#if defined (HAVE_TM_GMTOFF)
   t.tm_gmtoff = tm.gmtoff ();
 #endif
 
@@ -159,7 +159,7 @@
       t.tm_yday = tm_yday;
       t.tm_isdst = tm_isdst;
 
-#if defined (HAVE_STRUCT_TM_GMTOFF)
+#if defined (HAVE_TM_GMTOFF)
       t.tm_gmtoff = tm_gmtoff;
 #endif
 
@@ -215,7 +215,7 @@
   tm_yday = t->tm_yday;
   tm_isdst = t->tm_isdst;
 
-#if defined (HAVE_STRUCT_TM_GMTOFF)
+#if defined (HAVE_TM_GMTOFF)
   tm_gmtoff = t->tm_gmtoff;
 #endif
 
@@ -263,7 +263,7 @@
   t.tm_yday = 0;
   t.tm_isdst = 0;
 
-#if defined (HAVE_STRUCT_TM_GMTOFF)
+#if defined (HAVE_TM_GMTOFF)
   t.tm_gmtoff = 0;
 #endif