43 m.
assign (
"usec", static_cast<double> (t.
usec ()));
44 m.
assign (
"sec", static_cast<double> (t.
sec ()));
45 m.
assign (
"min", static_cast<double> (t.
min ()));
46 m.
assign (
"hour", static_cast<double> (t.
hour ()));
47 m.
assign (
"mday", static_cast<double> (t.
mday ()));
48 m.
assign (
"mon", static_cast<double> (t.
mon ()));
49 m.
assign (
"year", static_cast<double> (t.
year ()));
50 m.
assign (
"wday", static_cast<double> (t.
wday ()));
51 m.
assign (
"yday", static_cast<double> (t.
yday ()));
52 m.
assign (
"isdst", static_cast<double> (t.
isdst ()));
71 static inline std::string
106 @deftypefn {Built-in Function} {@var{seconds} =} time ()\n\
107 Return the current time as the number of seconds since the epoch. The\n\
108 epoch is referenced to 00:00:00 CUT (Coordinated Universal Time) 1 Jan\n\
109 1970. For example, on Monday February 17, 1997 at 07:15:06 CUT, the\n\
110 value returned by @code{time} was 856163706.\n\
111 @seealso{strftime, strptime, localtime, gmtime, mktime, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
116 if (args.length () == 0)
128 DEFUN (gmtime, args, ,
130 @deftypefn {Built-in Function} {@var{tm_struct} =} gmtime (@var{t})\n\
131 Given a value returned from @code{time}, or any non-negative integer,\n\
132 return a time structure corresponding to CUT (Coordinated Universal Time).\n\
153 @seealso{strftime, strptime, localtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
158 if (args.length () == 1)
190 DEFUN (localtime, args, ,
192 @deftypefn {Built-in Function} {@var{tm_struct} =} localtime (@var{t})\n\
193 Given a value returned from @code{time}, or any non-negative integer,\n\
194 return a time structure corresponding to the local time zone.\n\
198 localtime (time ())\n\
214 @seealso{strftime, strptime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
219 if (args.length () == 1)
251 DEFUN (mktime, args, ,
253 @deftypefn {Built-in Function} {@var{seconds} =} mktime (@var{tm_struct})\n\
254 Convert a time structure corresponding to the local time to the number\n\
255 of seconds since the epoch. For example:\n\
259 mktime (localtime (time ()))\n\
260 @result{} 856163706\n\
263 @seealso{strftime, strptime, localtime, gmtime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
268 if (args.length () == 1)
279 error (
"mktime: invalid TM_STRUCT argument");
282 error (
"mktime: TM_STRUCT argument must be a structure");
305 DEFUN (strftime, args, ,
307 @deftypefn {Built-in Function} {} strftime (@var{fmt}, @var{tm_struct})\n\
308 Format the time structure @var{tm_struct} in a flexible way using the\n\
309 format string @var{fmt} that contains @samp{%} substitutions\n\
310 similar to those in @code{printf}. Except where noted, substituted\n\
311 fields have a fixed size; numeric fields are padded if necessary.\n\
312 Padding is with zeros by default; for fields that display a single\n\
313 number, padding can be changed or inhibited by following the @samp{%}\n\
314 with one of the modifiers described below. Unknown field specifiers are\n\
315 copied as normal characters. All other characters are copied to the\n\
316 output without change. For example:\n\
320 strftime (\"%r (%Z) %A %e %B %Y\", localtime (time ()))\n\
321 @result{} \"01:15:06 AM (CST) Monday 17 February 1997\"\n\
325 Octave's @code{strftime} function supports a superset of the ANSI C\n\
329 Literal character fields:\n\
336 Newline character.\n\
343 Numeric modifiers (a nonstandard extension):\n\
347 Do not pad the field.\n\
349 @item _ (underscore)\n\
350 Pad the field with spaces.\n\
373 Locale's AM or PM.\n\
376 Time, 12-hour (hh:mm:ss [AP]M).\n\
379 Time, 24-hour (hh:mm).\n\
382 Time in seconds since 00:00:00, Jan 1, 1970 (a nonstandard extension).\n\
388 Time, 24-hour (hh:mm:ss).\n\
391 Locale's time representation (%H:%M:%S).\n\
394 Time zone (EDT), or nothing if no time zone is determinable.\n\
402 Locale's abbreviated weekday name (Sun-Sat).\n\
405 Locale's full weekday name, variable length (Sunday-Saturday).\n\
408 Locale's abbreviated month name (Jan-Dec).\n\
411 Locale's full month name, variable length (January-December).\n\
414 Locale's date and time (Sat Nov 04 12:02:33 EST 1989).\n\
420 Day of month (01-31).\n\
423 Day of month ( 1-31).\n\
432 Day of year (001-366).\n\
438 Week number of year with Sunday as first day of week (00-53).\n\
441 Day of week (0-6).\n\
444 Week number of year with Monday as first day of week (00-53).\n\
447 Locale's date representation (mm/dd/yy).\n\
450 Last two digits of year (00-99).\n\
455 @seealso{strptime, localtime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
460 if (args.length () == 2)
475 error (
"strftime: invalid TM_STRUCT argument");
478 error (
"strftime: TM_STRUCT must be a structure");
481 error (
"strftime: FMT must be a string");
500 DEFUN (strptime, args, ,
502 @deftypefn {Built-in Function} {[@var{tm_struct}, @var{nchars}] =} strptime (@var{str}, @var{fmt})\n\
503 Convert the string @var{str} to the time structure @var{tm_struct} under\n\
504 the control of the format string @var{fmt}.\n\
506 If @var{fmt} fails to match, @var{nchars} is 0; otherwise, it is set to the\n\
507 position of last matched character plus 1. Always check for this unless\n\
508 you're absolutely sure the date string will be parsed correctly.\n\
509 @seealso{strftime, localtime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
514 if (args.length () == 2)
516 std::string str = args(0).string_value ();
520 std::string fmt = args(1).string_value ();
530 error (
"strptime: FMT must be a string");
533 error (
"strptime: argument STR must be a string");