annotate libinterp/corefcn/time.cc @ 31607:aac27ad79be6 stable

maint: Re-indent code after switch to using namespace macros. * build-env.h, build-env.in.cc, Cell.h, __betainc__.cc, __eigs__.cc, __ftp__.cc, __ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __magick_read__.cc, __pchip_deriv__.cc, amd.cc, base-text-renderer.cc, base-text-renderer.h, besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, dasrt.cc, data.cc, debug.cc, defaults.cc, defaults.h, det.cc, display.cc, display.h, dlmread.cc, dynamic-ld.cc, dynamic-ld.h, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, gsvd.cc, gtk-manager.cc, gtk-manager.h, help.cc, help.h, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, inv.cc, jsondecode.cc, jsonencode.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-hdf5.cc, ls-mat4.cc, ls-mat5.cc, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mexproto.h, mxarray.h, mxtypes.in.h, oct-errno.in.cc, oct-hdf5-types.cc, oct-hist.cc, oct-hist.h, oct-map.cc, oct-map.h, oct-opengl.h, oct-prcstrm.h, oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.h, octave-default-image.h, ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-output.cc, psi.cc, qr.cc, quadcc.cc, rand.cc, regexp.cc, settings.cc, settings.h, sighandlers.cc, sighandlers.h, sparse-xpow.cc, sqrtm.cc, stack-frame.cc, stack-frame.h, stream-euler.cc, strfns.cc, svd.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, xdiv.cc, __delaunayn__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audioread.cc, convhulln.cc, gzip.cc, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, ov-base-diag.cc, ov-base-int.cc, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool.cc, ov-builtin.h, ov-cell.cc, ov-ch-mat.cc, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-intx.h, ov-java.cc, ov-lazy-idx.cc, ov-legacy-range.cc, ov-magic-int.cc, ov-mex-fcn.cc, ov-mex-fcn.h, ov-null-mat.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, ovl.h, octave.cc, octave.h, op-b-sbm.cc, op-bm-sbm.cc, op-cs-scm.cc, op-fm-fcm.cc, op-fs-fcm.cc, op-s-scm.cc, op-scm-cs.cc, op-scm-s.cc, op-sm-cs.cc, ops.h, anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, oct-lvalue.cc, oct-lvalue.h, parse.h, profiler.cc, profiler.h, pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h, range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc, chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h, base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h, file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h: Re-indent code after switch to using namespace macros.
author Rik <rik@octave.org>
date Thu, 01 Dec 2022 18:02:15 -0800
parents e88a07dec498
children 597f3ee61a48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30329
diff changeset
3 // Copyright (C) 1996-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21317
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
27 # include "config.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
28 #endif
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
29
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
30 #include <string>
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
31
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14501
diff changeset
32 #include "defun.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
33 #include "error.h"
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
34 #include "oct-map.h"
3254
28d5f556b8cf [project @ 1999-07-15 16:02:57 by jwe]
jwe
parents: 3233
diff changeset
35 #include "oct-time.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
36 #include "ov.h"
20940
48b2ad5ee801 maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents: 20939
diff changeset
37 #include "ovl.h"
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
38
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30888
diff changeset
39 OCTAVE_BEGIN_NAMESPACE(octave)
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
40
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
41 // Date and time functions.
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
42
11042
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
43 static octave_scalar_map
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
44 mk_tm_map (const sys::base_tm& t)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
45 {
11042
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
46 octave_scalar_map m;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
47
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4367
diff changeset
48 m.assign ("usec", static_cast<double> (t.usec ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4367
diff changeset
49 m.assign ("sec", static_cast<double> (t.sec ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4367
diff changeset
50 m.assign ("min", static_cast<double> (t.min ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4367
diff changeset
51 m.assign ("hour", static_cast<double> (t.hour ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4367
diff changeset
52 m.assign ("mday", static_cast<double> (t.mday ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4367
diff changeset
53 m.assign ("mon", static_cast<double> (t.mon ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4367
diff changeset
54 m.assign ("year", static_cast<double> (t.year ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4367
diff changeset
55 m.assign ("wday", static_cast<double> (t.wday ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4367
diff changeset
56 m.assign ("yday", static_cast<double> (t.yday ()));
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4367
diff changeset
57 m.assign ("isdst", static_cast<double> (t.isdst ()));
20375
31f89b12aaf7 strftime: Add support for "%z" conversion specifier (bug #45592)
Mike Miller <mtmiller@octave.org>
parents: 20172
diff changeset
58 m.assign ("gmtoff", static_cast<double> (t.gmtoff ()));
4675
f6d6335c08f6 [project @ 2003-12-16 05:11:26 by jwe]
jwe
parents: 4367
diff changeset
59 m.assign ("zone", t.zone ());
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
60
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
61 return m;
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
62 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
63
11042
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
64 static inline int
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
65 intfield (const octave_scalar_map& m, const std::string& k, const char *who)
11042
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
66 {
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
67 int retval = 0;
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
68
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
69 octave_value v = m.getfield (k);
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
70
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23220
diff changeset
71 if (! v.isempty ())
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
72 retval = v.xint_value ("%s: invalid TM_STRUCT argument", who);
11042
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
73
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
74 return retval;
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
75 }
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
76
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
77 static inline std::string
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
78 stringfield (const octave_scalar_map& m, const std::string& k, const char *who)
11042
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
79 {
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
80 std::string retval;
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
81
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
82 octave_value v = m.getfield (k);
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
83
23577
80c42f4cca13 maint: Deprecate is_empty and replace with isempty.
Rik <rik@octave.org>
parents: 23220
diff changeset
84 if (! v.isempty ())
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
85 retval = v.xstring_value ("%s: invalid TM_STRUCT argument", who);
11042
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
86
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
87 return retval;
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
88 }
f6b7b6e5b8b8 time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents: 11005
diff changeset
89
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
90 static sys::base_tm
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
91 extract_tm (const octave_scalar_map& m, const char *who)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
92 {
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
93 sys::base_tm tm;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
94
20704
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
95 tm.usec (intfield (m, "usec", who));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
96 tm.sec (intfield (m, "sec", who));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
97 tm.min (intfield (m, "min", who));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
98 tm.hour (intfield (m, "hour", who));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
99 tm.mday (intfield (m, "mday", who));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
100 tm.mon (intfield (m, "mon", who));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
101 tm.year (intfield (m, "year", who));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
102 tm.wday (intfield (m, "wday", who));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
103 tm.yday (intfield (m, "yday", who));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
104 tm.isdst (intfield (m, "isdst", who));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
105 tm.gmtoff (intfield (m, "gmtoff", who));
571508c1ed06 eliminate more uses of error_state
John W. Eaton <jwe@octave.org>
parents: 20700
diff changeset
106 tm.zone (stringfield (m, "zone", who));
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
107
3254
28d5f556b8cf [project @ 1999-07-15 16:02:57 by jwe]
jwe
parents: 3233
diff changeset
108 return tm;
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
109 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
110
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14501
diff changeset
111 DEFUN (time, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
112 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
113 @deftypefn {} {@var{seconds} =} time ()
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
114 Return the current time as the number of seconds since the epoch.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
115
25387
6cf9d00ad848 Use correct abbreviation UTC for Coordinated Universal Time (bug #53918).
Rik <rik@octave.org>
parents: 25054
diff changeset
116 The epoch is referenced to 00:00:00 UTC (Coordinated Universal Time) 1 Jan
6cf9d00ad848 Use correct abbreviation UTC for Coordinated Universal Time (bug #53918).
Rik <rik@octave.org>
parents: 25054
diff changeset
117 1970. For example, on Monday February 17, 1997 at 07:15:06 UTC, the value
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
118 returned by @code{time} was 856163706.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
119 @seealso{strftime, strptime, localtime, gmtime, mktime, now, date, clock,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
120 datenum, datestr, datevec, calendar, weekday}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
121 @end deftypefn */)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
122 {
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
123 if (args.length () != 0)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5688
diff changeset
124 print_usage ();
3255
4d33b1e56bff [project @ 1999-07-15 20:54:14 by jwe]
jwe
parents: 3254
diff changeset
125
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
126 return ovl (sys::time ());
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
127 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
128
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
129 /*
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
130 %!assert (time () > 0)
19142
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
131
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
132 %!error time (1)
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
133 */
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
134
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14501
diff changeset
135 DEFUN (gmtime, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
136 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
137 @deftypefn {} {@var{tm_struct} =} gmtime (@var{t})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
138 Given a value returned from @code{time}, or any non-negative integer,
25387
6cf9d00ad848 Use correct abbreviation UTC for Coordinated Universal Time (bug #53918).
Rik <rik@octave.org>
parents: 25054
diff changeset
139 return a time structure corresponding to UTC (Coordinated Universal Time).
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
140
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
141 For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
142
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
143 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
144 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
145 gmtime (time ())
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
146 @result{} @{
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
147 usec = 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
148 sec = 6
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
149 min = 15
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
150 hour = 7
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
151 mday = 17
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
152 mon = 1
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
153 year = 97
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
154 wday = 1
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
155 yday = 47
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
156 isdst = 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
157 gmtoff = 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
158 zone = GMT
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
159 @}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
160 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
161 @end example
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
162 @seealso{strftime, strptime, localtime, mktime, time, now, date, clock, datenum,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
163 datestr, datevec, calendar, weekday}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
164 @end deftypefn */)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
165 {
27058
f6e59ee37fee Emit an error if localtime or gmtime is called with a non-scalar argument (bug #56190).
Rik <rik@octave.org>
parents: 26376
diff changeset
166 if (args.length () != 1 || args(0).numel () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5688
diff changeset
167 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
168
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
169 double tmp = args(0).double_value ();
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
170
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
171 return ovl (mk_tm_map (sys::gmtime (tmp)));
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
172 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
173
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
174 /*
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
175 %!test
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
176 %! ts = gmtime (time ());
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
177 %! assert (isstruct (ts));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
178 %! assert (isfield (ts, "usec"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
179 %! assert (isfield (ts, "year"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
180 %! assert (isfield (ts, "mon"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
181 %! assert (isfield (ts, "mday"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
182 %! assert (isfield (ts, "sec"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
183 %! assert (isfield (ts, "min"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
184 %! assert (isfield (ts, "wday"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
185 %! assert (isfield (ts, "hour"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
186 %! assert (isfield (ts, "isdst"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
187 %! assert (isfield (ts, "yday"));
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
188
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
189 %!error gmtime ()
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
190 %!error gmtime (1, 2)
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
191 */
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
192
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14501
diff changeset
193 DEFUN (localtime, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
194 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
195 @deftypefn {} {@var{tm_struct} =} localtime (@var{t})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
196 Given a value returned from @code{time}, or any non-negative integer,
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
197 return a time structure corresponding to the local time zone.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
198
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
199 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
200 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
201 localtime (time ())
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
202 @result{} @{
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
203 usec = 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
204 sec = 6
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
205 min = 15
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
206 hour = 1
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
207 mday = 17
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
208 mon = 1
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
209 year = 97
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
210 wday = 1
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
211 yday = 47
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
212 isdst = 0
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
213 gmtoff = -21600
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
214 zone = CST
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
215 @}
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
216 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
217 @end example
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
218 @seealso{strftime, strptime, gmtime, mktime, time, now, date, clock, datenum,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
219 datestr, datevec, calendar, weekday}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
220 @end deftypefn */)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
221 {
27058
f6e59ee37fee Emit an error if localtime or gmtime is called with a non-scalar argument (bug #56190).
Rik <rik@octave.org>
parents: 26376
diff changeset
222 if (args.length () != 1 || args(0).numel () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5688
diff changeset
223 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
224
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
225 double tmp = args(0).double_value ();
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
226
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
227 return ovl (mk_tm_map (sys::localtime (tmp)));
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
228 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
229
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
230 /*
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
231 %!test
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
232 %! ts = localtime (time ());
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
233 %! assert (isstruct (ts));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
234 %! assert (isfield (ts, "usec"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
235 %! assert (isfield (ts, "year"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
236 %! assert (isfield (ts, "mon"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
237 %! assert (isfield (ts, "mday"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
238 %! assert (isfield (ts, "sec"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
239 %! assert (isfield (ts, "min"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
240 %! assert (isfield (ts, "wday"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
241 %! assert (isfield (ts, "hour"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
242 %! assert (isfield (ts, "isdst"));
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
243 %! assert (isfield (ts, "yday"));
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
244
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
245 %!error localtime ()
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
246 %!error localtime (1, 2)
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
247 */
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
248
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14501
diff changeset
249 DEFUN (mktime, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
250 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
251 @deftypefn {} {@var{seconds} =} mktime (@var{tm_struct})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
252 Convert a time structure corresponding to the local time to the number of
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
253 seconds since the epoch.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
254
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
255 For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
256
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
257 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
258 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
259 mktime (localtime (time ()))
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
260 @result{} 856163706
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
261 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
262 @end example
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
263 @seealso{strftime, strptime, localtime, gmtime, time, now, date, clock, datenum,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
264 datestr, datevec, calendar, weekday}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
265 @end deftypefn */)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
266 {
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
267 if (args.length () != 1)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5688
diff changeset
268 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
269
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
270 octave_scalar_map map = args(
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
271 0).xscalar_map_value ("mktime: TM_STRUCT argument must be a structure");
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
272
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
273 sys::base_tm tm = extract_tm (map, "mktime");
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
274
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
275 return ovl (sys::time (tm));
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
276 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
277
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
278 /*
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
279 %!test
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
280 %! t = time ();
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
281 %! assert (fix (mktime (localtime (t))) == fix (t));
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
282
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
283 ## These tests fail on systems with mktime functions of limited
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
284 ## intelligence:
11005
0de4eff677d6 use mktime module from gnulib
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
285 %!assert (datestr (datenum (1969, 1, 1), 0), "01-Jan-1969 00:00:00")
0de4eff677d6 use mktime module from gnulib
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
286 %!assert (datestr (datenum (1901, 1, 1), 0), "01-Jan-1901 00:00:00")
0de4eff677d6 use mktime module from gnulib
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
287 %!assert (datestr (datenum (1795, 1, 1), 0), "01-Jan-1795 00:00:00")
0de4eff677d6 use mktime module from gnulib
John W. Eaton <jwe@octave.org>
parents: 10840
diff changeset
288
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
289 %!error mktime ()
19142
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
290 %!error mktime (1)
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
291 %!error mktime (1, 2, 3)
19142
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
292 %!error mktime (struct ("year", "foo"))
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
293 */
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
294
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14501
diff changeset
295 DEFUN (strftime, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
296 doc: /* -*- texinfo -*-
30888
32d2b6604a9f doc: Ensure documentation lists output argument when it exists for functions in libinterp/
Rik <rik@octave.org>
parents: 30564
diff changeset
297 @deftypefn {} {@var{str} =} strftime (@var{fmt}, @var{tm_struct})
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
298 Format the time structure @var{tm_struct} in a flexible way using the format
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
299 string @var{fmt} that contains @samp{%} substitutions similar to those in
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
300 @code{printf}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
301
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
302 Except where noted, substituted fields have a fixed size; numeric fields are
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
303 padded if necessary. Padding is with zeros by default; for fields that
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
304 display a single number, padding can be changed or inhibited by following
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
305 the @samp{%} with one of the modifiers described below. Unknown field
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
306 specifiers are copied as normal characters. All other characters are copied
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
307 to the output without change. For example:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
308
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
309 @example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
310 @group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
311 strftime ("%r (%Z) %A %e %B %Y", localtime (time ()))
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
312 @result{} "01:15:06 AM (CST) Monday 17 February 1997"
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
313 @end group
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
314 @end example
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
315
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
316 Octave's @code{strftime} function supports a superset of the ANSI C field
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
317 specifiers.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
318
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
319 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
320 Literal character fields:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
321
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
322 @table @code
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
323 @item %%
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
324 % character.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
325
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
326 @item %n
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
327 Newline character.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
328
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
329 @item %t
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
330 Tab character.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
331 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
332
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
333 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
334 Numeric modifiers (a nonstandard extension):
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
335
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
336 @table @code
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
337 @item - (dash)
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
338 Do not pad the field.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
339
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
340 @item _ (underscore)
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
341 Pad the field with spaces.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
342 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
343
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
344 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
345 Time fields:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
346
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
347 @table @code
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
348 @item %H
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
349 Hour (00-23).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
350
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
351 @item %I
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
352 Hour (01-12).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
353
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
354 @item %k
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
355 Hour (0-23).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
356
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
357 @item %l
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
358 Hour (1-12).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
359
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
360 @item %M
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
361 Minute (00-59).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
362
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
363 @item %p
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
364 Locale's AM or PM.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
365
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
366 @item %r
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
367 Time, 12-hour (hh:mm:ss [AP]M).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
368
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
369 @item %R
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
370 Time, 24-hour (hh:mm).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
371
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
372 @item %s
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
373 Time in seconds since 00:00:00, Jan 1, 1970 (a nonstandard extension).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
374
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
375 @item %S
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
376 Second (00-61).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
377
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
378 @item %T
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
379 Time, 24-hour (hh:mm:ss).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
380
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
381 @item %X
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
382 Locale's time representation (%H:%M:%S).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
383
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
384 @item %z
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
385 Offset from UTC (±@nospell{hhmm}), or nothing if no time zone is
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
386 determinable.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
387
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
388 @item %Z
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
389 Time zone (EDT), or nothing if no time zone is determinable.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
390 @end table
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
391
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
392 @noindent
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
393 Date fields:
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
394
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
395 @table @code
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
396 @item %a
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
397 Locale's abbreviated weekday name (Sun-Sat).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
398
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
399 @item %A
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
400 Locale's full weekday name, variable length (Sunday-Saturday).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
401
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
402 @item %b
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
403 Locale's abbreviated month name (Jan-Dec).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
404
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
405 @item %B
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
406 Locale's full month name, variable length (January-December).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
407
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
408 @item %c
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
409 Locale's date and time (Sat Nov 04 12:02:33 EST 1989).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
410
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
411 @item %C
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
412 Century (00-99).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
413
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
414 @item %d
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
415 Day of month (01-31).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
416
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
417 @item %e
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
418 Day of month ( 1-31).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
419
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
420 @item %D
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
421 Date (mm/dd/yy).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
422
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
423 @item %h
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
424 Same as %b.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
425
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
426 @item %j
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
427 Day of year (001-366).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
428
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
429 @item %m
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
430 Month (01-12).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
431
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
432 @item %U
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
433 Week number of year with Sunday as first day of week (00-53).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
434
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
435 @item %w
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
436 Day of week (0-6).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
437
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
438 @item %W
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
439 Week number of year with Monday as first day of week (00-53).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
440
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
441 @item %x
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
442 Locale's date representation (mm/dd/yy).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
443
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
444 @item %y
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
445 Last two digits of year (00-99).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
446
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
447 @item %Y
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
448 Year (1970-).
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
449 @end table
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
450 @seealso{strptime, localtime, gmtime, mktime, time, now, date, clock, datenum,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
451 datestr, datevec, calendar, weekday}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
452 @end deftypefn */)
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
453 {
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
454 if (args.length () != 2)
5823
080c08b192d8 [project @ 2006-05-19 05:32:17 by jwe]
jwe
parents: 5688
diff changeset
455 print_usage ();
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
456
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
457 std::string fmt = args(0).xstring_value ("strftime: FMT must be a string");
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
458
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
459 octave_scalar_map map = args(1).xscalar_map_value ("strftime: TM_STRUCT must be a structure");
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
460
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
461 sys::base_tm tm = extract_tm (map, "strftime");
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
462
20939
b17fda023ca6 maint: Use new C++ archetype in more files.
Rik <rik@octave.org>
parents: 20882
diff changeset
463 return ovl (tm.strftime (fmt));
2928
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
464 }
295f037b4b3e [project @ 1997-05-05 05:32:33 by jwe]
jwe
parents:
diff changeset
465
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
466 /*
21317
a4faec57f4c8 maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents: 21301
diff changeset
467 %!assert (ischar (strftime ("%%%n%t%H%I%k%l", localtime (time ()))))
a4faec57f4c8 maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents: 21301
diff changeset
468 %!assert (ischar (strftime ("%M%p%r%R%s%S%T", localtime (time ()))))
a4faec57f4c8 maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents: 21301
diff changeset
469 %!assert (ischar (strftime ("%X%Z%z%a%A%b%B", localtime (time ()))))
a4faec57f4c8 maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents: 21301
diff changeset
470 %!assert (ischar (strftime ("%c%C%d%e%D%h%j", localtime (time ()))))
a4faec57f4c8 maint: remove semicolon after %!assert tests to follow Octave conventions.
Rik <rik@octave.org>
parents: 21301
diff changeset
471 %!assert (ischar (strftime ("%m%U%w%W%x%y%Y", localtime (time ()))))
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
472
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
473 %!error strftime ()
19142
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
474 %!error strftime ("foo", 1)
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
475 %!error strftime ("foo", struct ("year", "foo"))
14501
60e5cf354d80 Update %!tests in DLD-FUNCTIONS/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents: 14360
diff changeset
476 %!error strftime ("foo", localtime (time ()), 1)
7562
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
477 */
c827f5673321 move tests to individual source files
John W. Eaton <jwe@octave.org>
parents: 7097
diff changeset
478
15039
e753177cde93 maint: Move non-dynamically linked functions from DLD-FUNCTIONS/ to corefcn/ directory
Rik <rik@octave.org>
parents: 14501
diff changeset
479 DEFUN (strptime, args, ,
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
480 doc: /* -*- texinfo -*-
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
481 @deftypefn {} {[@var{tm_struct}, @var{nchars}] =} strptime (@var{str}, @var{fmt})
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
482 Convert the string @var{str} to the time structure @var{tm_struct} under
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
483 the control of the format string @var{fmt}.
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
484
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
485 If @var{fmt} fails to match, @var{nchars} is 0; otherwise, it is set to the
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
486 position of last matched character plus 1. Always check for this unless
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
487 you're absolutely sure the date string will be parsed correctly.
30329
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
488 @seealso{strftime, localtime, gmtime, mktime, time, now, date, clock, datenum,
81d26e8481a6 maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents: 29961
diff changeset
489 datestr, datevec, calendar, weekday}
21966
112b20240c87 move docstrings in C++ files out of C strings and into comments
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
490 @end deftypefn */)
3465
996bb7ea4507 [project @ 2000-01-21 07:48:25 by jwe]
jwe
parents: 3325
diff changeset
491 {
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
492 if (args.length () != 2)
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
493 print_usage ();
3465
996bb7ea4507 [project @ 2000-01-21 07:48:25 by jwe]
jwe
parents: 3325
diff changeset
494
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
495 std::string str = args(0).xstring_value ("strptime: argument STR must be a string");
19403
03067dab10ca Use stricter input validation when looking for a string as input (bug #42651).
Rik <rik@octave.org>
parents: 19142
diff changeset
496
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
497 std::string fmt = args(1).xstring_value ("strptime: FMT must be a string");
3465
996bb7ea4507 [project @ 2000-01-21 07:48:25 by jwe]
jwe
parents: 3325
diff changeset
498
29961
7d6709900da7 eliminate octave:: namespace tags in DEFUN and DEFMETHOD and more
John W. Eaton <jwe@octave.org>
parents: 29958
diff changeset
499 sys::strptime t (str, fmt);
20800
fb128aafc322 eliminate return statements after calls to print_usage
John W. Eaton <jwe@octave.org>
parents: 20719
diff changeset
500
20882
776c0b8c1d07 2015 Code Sprint: time.cc: use ovl ().
Rik <rik@octave.org>
parents: 20880
diff changeset
501 return ovl (mk_tm_map (t), t.characters_converted ());
3465
996bb7ea4507 [project @ 2000-01-21 07:48:25 by jwe]
jwe
parents: 3325
diff changeset
502 }
19142
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
503
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
504 /*
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
505 %!test
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
506 %! fmt = "%Y-%m-%d %H:%M:%S";
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
507 %! s = strftime (fmt, localtime (time ()));
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
508 %! ts = strptime (s, fmt);
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
509 %! assert (isstruct (ts));
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
510 %! assert (isfield (ts, "usec"));
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
511 %! assert (isfield (ts, "year"));
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
512 %! assert (isfield (ts, "mon"));
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
513 %! assert (isfield (ts, "mday"));
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
514 %! assert (isfield (ts, "sec"));
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
515 %! assert (isfield (ts, "min"));
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
516 %! assert (isfield (ts, "wday"));
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
517 %! assert (isfield (ts, "hour"));
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
518 %! assert (isfield (ts, "isdst"));
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
519 %! assert (isfield (ts, "yday"));
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
520
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
521 %!error strptime ()
b8bd0b55af45 codesprint: Add tests to time handling functions
Mike Miller <mtmiller@ieee.org>
parents: 17787
diff changeset
522 */
29958
32c3a5805893 move DEFUN and DEFMETHOD functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
523
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30888
diff changeset
524 OCTAVE_END_NAMESPACE(octave)