26#if defined (HAVE_CONFIG_H)
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 ());
72 retval = v.
xint_value (
"%s: invalid TM_STRUCT argument", who);
77static inline std::string
85 retval = v.
xstring_value (
"%s: invalid TM_STRUCT argument", 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));
123 if (args.length () != 0)
126 return ovl (sys::time ());
135DEFUN (gmtime, args, ,
166 if (args.length () != 1 || args(0).
numel () != 1)
169 double tmp = args(0).double_value ();
193DEFUN (localtime, args, ,
222 if (args.length () != 1 || args(0).
numel () != 1)
225 double tmp = args(0).double_value ();
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");
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));
478DEFUN (strptime, args, ,
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);
void assign(const std::string &k, const octave_value &val)
octave_value getfield(const std::string &key) const
OCTINTERP_API std::string xstring_value(const char *fmt,...) const
OCTINTERP_API int xint_value(const char *fmt,...) const
OCTINTERP_API void print_usage(void)
#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.
static std::string stringfield(const octave_scalar_map &m, const std::string &k, const char *who)
static int intfield(const octave_scalar_map &m, const std::string &k, const char *who)
static OCTAVE_NAMESPACE_BEGIN octave_scalar_map mk_tm_map(const sys::base_tm &t)
static sys::base_tm extract_tm(const octave_scalar_map &m, const char *who)