26#if defined (HAVE_CONFIG_H)
44mk_tm_map (
const sys::base_tm& t)
48 m.
assign (
"usec",
static_cast<double> (t.usec ()));
49 m.
assign (
"sec",
static_cast<double> (t.sec ()));
50 m.
assign (
"min",
static_cast<double> (t.min ()));
51 m.
assign (
"hour",
static_cast<double> (t.hour ()));
52 m.
assign (
"mday",
static_cast<double> (t.mday ()));
53 m.
assign (
"mon",
static_cast<double> (t.mon ()));
54 m.
assign (
"year",
static_cast<double> (t.year ()));
55 m.
assign (
"wday",
static_cast<double> (t.wday ()));
56 m.
assign (
"yday",
static_cast<double> (t.yday ()));
57 m.
assign (
"isdst",
static_cast<double> (t.isdst ()));
58 m.
assign (
"gmtoff",
static_cast<double> (t.gmtoff ()));
59 m.
assign (
"zone", t.zone ());
77static inline std::string
85 retval = v.
xstring_value (
"%s: invalid TM_STRUCT argument", who);
95 tm.usec (intfield (m,
"usec", who));
96 tm.sec (intfield (m,
"sec", who));
97 tm.min (intfield (m,
"min", who));
98 tm.hour (intfield (m,
"hour", who));
99 tm.mday (intfield (m,
"mday", who));
100 tm.mon (intfield (m,
"mon", who));
101 tm.year (intfield (m,
"year", who));
102 tm.wday (intfield (m,
"wday", who));
103 tm.yday (intfield (m,
"yday", who));
104 tm.isdst (intfield (m,
"isdst", who));
105 tm.gmtoff (intfield (m,
"gmtoff", who));
106 tm.zone (stringfield (m,
"zone", who));
123 if (args.length () != 0)
126 return ovl (sys::time ());
166 if (args.length () != 1 || args(0).
numel () != 1)
169 double tmp = args(0).double_value ();
171 return ovl (mk_tm_map (sys::gmtime (tmp)));
222 if (args.length () != 1 || args(0).
numel () != 1)
225 double tmp = args(0).double_value ();
227 return ovl (mk_tm_map (sys::localtime (tmp)));
249DEFUN (mktime, args, ,
267 if (args.length () != 1)
270 octave_scalar_map map = args(0).xscalar_map_value (
"mktime: TM_STRUCT argument must be a structure");
272 sys::base_tm tm = extract_tm (map,
"mktime");
274 return ovl (sys::time (tm));
294DEFUN (strftime, args, ,
453 if (args.length () != 2)
456 std::string fmt = args(0).xstring_value (
"strftime: FMT must be a string");
458 octave_scalar_map map = args(1).xscalar_map_value (
"strftime: TM_STRUCT must be a structure");
460 sys::base_tm tm = extract_tm (map,
"strftime");
462 return ovl (tm.strftime (fmt));
491 if (args.length () != 2)
494 std::string str = args(0).xstring_value (
"strptime: argument STR must be a string");
496 std::string fmt = args(1).xstring_value (
"strptime: FMT must be a string");
498 sys::strptime t (str, fmt);
500 return ovl (mk_tm_map (t), t.characters_converted ());
523OCTAVE_END_NAMESPACE(octave)
void assign(const std::string &k, const octave_value &val)
octave_value getfield(const std::string &key) const
int strict_int_value(bool frc_str_conv=false) const
std::string xstring_value(const char *fmt,...) const
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
T::size_type numel(const T &str)
octave_value_list ovl(const OV_Args &... args)
Construct an octave_value_list with less typing.