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.\n\
109 The epoch is referenced to 00:00:00 CUT (Coordinated Universal Time) 1 Jan\n\
110 1970. For example, on Monday February 17, 1997 at 07:15:06 CUT, the value\n\
111 returned by @code{time} was 856163706.\n\
112 @seealso{strftime, strptime, localtime, gmtime, mktime, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
117 if (args.length () == 0)
131 DEFUN (gmtime, args, ,
133 @deftypefn {Built-in Function} {@var{tm_struct} =} gmtime (@var{t})\n\
134 Given a value returned from @code{time}, or any non-negative integer,\n\
135 return a time structure corresponding to CUT (Coordinated Universal Time).\n\
157 @seealso{strftime, strptime, localtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
162 if (args.length () == 1)
194 DEFUN (localtime, args, ,
196 @deftypefn {Built-in Function} {@var{tm_struct} =} localtime (@var{t})\n\
197 Given a value returned from @code{time}, or any non-negative integer,\n\
198 return a time structure corresponding to the local time zone.\n\
202 localtime (time ())\n\
218 @seealso{strftime, strptime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
223 if (args.length () == 1)
255 DEFUN (mktime, args, ,
257 @deftypefn {Built-in Function} {@var{seconds} =} mktime (@var{tm_struct})\n\
258 Convert a time structure corresponding to the local time to the number of\n\
259 seconds since the epoch.\n\
265 mktime (localtime (time ()))\n\
266 @result{} 856163706\n\
269 @seealso{strftime, strptime, localtime, gmtime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
274 if (args.length () == 1)
285 error (
"mktime: invalid TM_STRUCT argument");
288 error (
"mktime: TM_STRUCT argument must be a structure");
313 DEFUN (strftime, args, ,
315 @deftypefn {Built-in Function} {} strftime (@var{fmt}, @var{tm_struct})\n\
316 Format the time structure @var{tm_struct} in a flexible way using the format\n\
317 string @var{fmt} that contains @samp{%} substitutions similar to those in\n\
320 Except where noted, substituted fields have a fixed size; numeric fields are\n\
321 padded if necessary. Padding is with zeros by default; for fields that\n\
322 display a single number, padding can be changed or inhibited by following\n\
323 the @samp{%} with one of the modifiers described below. Unknown field\n\
324 specifiers are copied as normal characters. All other characters are copied\n\
325 to the output without change. For example:\n\
329 strftime (\"%r (%Z) %A %e %B %Y\", localtime (time ()))\n\
330 @result{} \"01:15:06 AM (CST) Monday 17 February 1997\"\n\
334 Octave's @code{strftime} function supports a superset of the ANSI C field\n\
338 Literal character fields:\n\
345 Newline character.\n\
352 Numeric modifiers (a nonstandard extension):\n\
356 Do not pad the field.\n\
358 @item _ (underscore)\n\
359 Pad the field with spaces.\n\
382 Locale's AM or PM.\n\
385 Time, 12-hour (hh:mm:ss [AP]M).\n\
388 Time, 24-hour (hh:mm).\n\
391 Time in seconds since 00:00:00, Jan 1, 1970 (a nonstandard extension).\n\
397 Time, 24-hour (hh:mm:ss).\n\
400 Locale's time representation (%H:%M:%S).\n\
403 Time zone (EDT), or nothing if no time zone is determinable.\n\
411 Locale's abbreviated weekday name (Sun-Sat).\n\
414 Locale's full weekday name, variable length (Sunday-Saturday).\n\
417 Locale's abbreviated month name (Jan-Dec).\n\
420 Locale's full month name, variable length (January-December).\n\
423 Locale's date and time (Sat Nov 04 12:02:33 EST 1989).\n\
429 Day of month (01-31).\n\
432 Day of month ( 1-31).\n\
441 Day of year (001-366).\n\
447 Week number of year with Sunday as first day of week (00-53).\n\
450 Day of week (0-6).\n\
453 Week number of year with Monday as first day of week (00-53).\n\
456 Locale's date representation (mm/dd/yy).\n\
459 Last two digits of year (00-99).\n\
464 @seealso{strptime, localtime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
469 if (args.length () == 2)
471 if (args(0).is_string ())
484 error (
"strftime: invalid TM_STRUCT argument");
487 error (
"strftime: TM_STRUCT must be a structure");
490 error (
"strftime: FMT must be a string");
511 DEFUN (strptime, args, ,
513 @deftypefn {Built-in Function} {[@var{tm_struct}, @var{nchars}] =} strptime (@var{str}, @var{fmt})\n\
514 Convert the string @var{str} to the time structure @var{tm_struct} under\n\
515 the control of the format string @var{fmt}.\n\
517 If @var{fmt} fails to match, @var{nchars} is 0; otherwise, it is set to the\n\
518 position of last matched character plus 1. Always check for this unless\n\
519 you're absolutely sure the date string will be parsed correctly.\n\
520 @seealso{strftime, localtime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\
525 if (args.length () == 2)
527 if (args(0).is_string ())
529 std::string str = args(0).string_value ();
531 if (args(1).is_string ())
533 std::string fmt = args(1).string_value ();
541 error (
"strptime: FMT must be a string");
544 error (
"strptime: argument STR must be a string");
OCTINTERP_API void print_usage(void)
std::string strftime(const std::string &fmt) const
std::string zone(void) const
int int_value(bool req_int=false, bool frc_str_conv=false) const
#define DEFUN(name, args_name, nargout_name, doc)
void error(const char *fmt,...)
int characters_converted(void) const
static std::string stringfield(const octave_scalar_map &m, const std::string &k)
static int intfield(const octave_scalar_map &m, const std::string &k)
std::string string_value(bool force=false) const
bool is_empty(void) const
void assign(const std::string &k, const octave_value &val)
octave_value getfield(const std::string &key) const
static octave_scalar_map mk_tm_map(const octave_base_tm &t)
double double_value(bool frc_str_conv=false) const
static octave_base_tm extract_tm(const octave_scalar_map &m)
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))