Mercurial > octave-nkf
annotate src/DLD-FUNCTIONS/time.cc @ 14361:8de863b7126b
doc: Use Octave preference for double quote in docstrings in all .cc files
* cellfun.cc, chol.cc, colamd.cc, dlmread.cc, eigs.cc, fftw.cc, lu.cc,
luinc.cc, matrix_type.cc, spparms.cc, symrcm.cc, data.cc, dirfns.cc, error.cc:
Use Octave preference for double quote in docstrings.
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Mon, 13 Feb 2012 07:45:41 -0800 |
parents | 97883071e8e4 |
children | 60e5cf354d80 |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13915
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
2928 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
2928 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
2928 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include <string> | |
28 | |
29 #include "defun-dld.h" | |
30 #include "error.h" | |
31 #include "oct-map.h" | |
3254 | 32 #include "oct-time.h" |
2928 | 33 #include "ov.h" |
34 #include "oct-obj.h" | |
35 | |
36 // Date and time functions. | |
37 | |
11042
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
38 static octave_scalar_map |
3254 | 39 mk_tm_map (const octave_base_tm& t) |
2928 | 40 { |
11042
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
41 octave_scalar_map m; |
2928 | 42 |
4675 | 43 m.assign ("usec", static_cast<double> (t.usec ())); |
44 m.assign ("sec", static_cast<double> (t.sec ())); | |
45 m.assign ("min", static_cast<double> (t.min ())); | |
46 m.assign ("hour", static_cast<double> (t.hour ())); | |
47 m.assign ("mday", static_cast<double> (t.mday ())); | |
48 m.assign ("mon", static_cast<double> (t.mon ())); | |
49 m.assign ("year", static_cast<double> (t.year ())); | |
50 m.assign ("wday", static_cast<double> (t.wday ())); | |
51 m.assign ("yday", static_cast<double> (t.yday ())); | |
52 m.assign ("isdst", static_cast<double> (t.isdst ())); | |
53 m.assign ("zone", t.zone ()); | |
2928 | 54 |
55 return m; | |
56 } | |
57 | |
11042
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
58 static inline int |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
59 intfield (const octave_scalar_map& m, const std::string& k) |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
60 { |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
61 int retval = 0; |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
62 |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
63 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
|
64 |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
65 if (! v.is_empty ()) |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
66 retval = v.int_value (); |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
67 |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
68 return retval; |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
69 } |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
70 |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
71 static inline std::string |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
72 stringfield (const octave_scalar_map& m, const std::string& k) |
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 std::string 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 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
|
77 |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
78 if (! v.is_empty ()) |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
79 retval = v.string_value (); |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
80 |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
81 return retval; |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
82 } |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
83 |
3254 | 84 static octave_base_tm |
11042
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
85 extract_tm (const octave_scalar_map& m) |
2928 | 86 { |
3254 | 87 octave_base_tm tm; |
2928 | 88 |
11042
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
89 tm.usec (intfield (m, "usec")); |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
90 tm.sec (intfield (m, "sec")); |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
91 tm.min (intfield (m, "min")); |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
92 tm.hour (intfield (m, "hour")); |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
93 tm.mday (intfield (m, "mday")); |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
94 tm.mon (intfield (m, "mon")); |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
95 tm.year (intfield (m, "year")); |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
96 tm.wday (intfield (m, "wday")); |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
97 tm.yday (intfield (m, "yday")); |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
98 tm.isdst (intfield (m, "isdst")); |
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
99 tm.zone (stringfield (m, "zone")); |
2928 | 100 |
3254 | 101 return tm; |
2928 | 102 } |
103 | |
3255 | 104 DEFUN_DLD (time, args, , |
3301 | 105 "-*- texinfo -*-\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
106 @deftypefn {Loadable Function} {@var{seconds} =} time ()\n\ |
3301 | 107 Return the current time as the number of seconds since the epoch. The\n\ |
108 epoch is referenced to 00:00:00 CUT (Coordinated Universal Time) 1 Jan\n\ | |
109 1970. For example, on Monday February 17, 1997 at 07:15:06 CUT, the\n\ | |
110 value returned by @code{time} was 856163706.\n\ | |
5688 | 111 @seealso{strftime, strptime, localtime, gmtime, mktime, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\ |
3301 | 112 @end deftypefn") |
2928 | 113 { |
3255 | 114 octave_value retval; |
2928 | 115 |
3255 | 116 if (args.length () == 0) |
7065 | 117 retval = octave_time (); |
3255 | 118 else |
5823 | 119 print_usage (); |
3255 | 120 |
121 return retval; | |
2928 | 122 } |
123 | |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
124 /* |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
125 |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
126 %!assert(time () > 0); |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
127 |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
128 */ |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
129 |
2928 | 130 DEFUN_DLD (gmtime, args, , |
3301 | 131 "-*- texinfo -*-\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
132 @deftypefn {Loadable Function} {@var{tm_struct} =} gmtime (@var{t})\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
133 Given a value returned from @code{time}, or any non-negative integer,\n\ |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11553
diff
changeset
|
134 return a time structure corresponding to CUT (Coordinated Universal Time).\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
135 For example:\n\ |
2928 | 136 \n\ |
3301 | 137 @example\n\ |
138 @group\n\ | |
139 gmtime (time ())\n\ | |
140 @result{} @{\n\ | |
141 usec = 0\n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
142 sec = 6\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
143 min = 15\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
144 hour = 7\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
145 mday = 17\n\ |
3301 | 146 mon = 1\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
147 year = 97\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
148 wday = 1\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
149 yday = 47\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
150 isdst = 0\n\ |
3301 | 151 zone = CST\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
152 @}\n\ |
3301 | 153 @end group\n\ |
154 @end example\n\ | |
5688 | 155 @seealso{strftime, strptime, localtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\ |
3301 | 156 @end deftypefn") |
2928 | 157 { |
3465 | 158 octave_value retval; |
2928 | 159 |
160 if (args.length () == 1) | |
161 { | |
162 double tmp = args(0).double_value (); | |
163 | |
164 if (! error_state) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
165 retval = octave_value (mk_tm_map (octave_gmtime (tmp))); |
2928 | 166 } |
167 else | |
5823 | 168 print_usage (); |
2928 | 169 |
170 return retval; | |
171 } | |
172 | |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
173 /* |
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 ()); |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
177 %! assert((isstruct (ts) |
10231
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
178 %! && isfield (ts, "usec") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
179 %! && isfield (ts, "year") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
180 %! && isfield (ts, "mon") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
181 %! && isfield (ts, "mday") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
182 %! && isfield (ts, "sec") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
183 %! && isfield (ts, "min") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
184 %! && isfield (ts, "wday") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
185 %! && isfield (ts, "hour") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
186 %! && isfield (ts, "isdst") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
187 %! && isfield (ts, "yday"))); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
188 |
13915
5fa482628bf6
Remove unnecessary regular expression '.*' from ends of %!error blocks
Rik <octave@nomad.inbox5.com>
parents:
12776
diff
changeset
|
189 %!error <Invalid call to gmtime> gmtime (); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
190 |
13915
5fa482628bf6
Remove unnecessary regular expression '.*' from ends of %!error blocks
Rik <octave@nomad.inbox5.com>
parents:
12776
diff
changeset
|
191 %!error <Invalid call to gmtime> gmtime (1, 2); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
192 |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
193 */ |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
194 |
2928 | 195 DEFUN_DLD (localtime, args, , |
3301 | 196 "-*- texinfo -*-\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
197 @deftypefn {Loadable Function} {@var{tm_struct} =} localtime (@var{t})\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
198 Given a value returned from @code{time}, or any non-negative integer,\n\ |
3301 | 199 return a time structure corresponding to the local time zone.\n\ |
2928 | 200 \n\ |
3301 | 201 @example\n\ |
202 @group\n\ | |
203 localtime (time ())\n\ | |
204 @result{} @{\n\ | |
205 usec = 0\n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
206 sec = 6\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
207 min = 15\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
208 hour = 1\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
209 mday = 17\n\ |
3301 | 210 mon = 1\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
211 year = 97\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
212 wday = 1\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
213 yday = 47\n\ |
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
214 isdst = 0\n\ |
3301 | 215 zone = CST\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
216 @}\n\ |
3301 | 217 @end group\n\ |
218 @end example\n\ | |
5688 | 219 @seealso{strftime, strptime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\ |
3301 | 220 @end deftypefn") |
2928 | 221 { |
3465 | 222 octave_value retval; |
2928 | 223 |
224 if (args.length () == 1) | |
225 { | |
226 double tmp = args(0).double_value (); | |
227 | |
228 if (! error_state) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
229 retval = octave_value (mk_tm_map (octave_localtime (tmp))); |
2928 | 230 } |
231 else | |
5823 | 232 print_usage (); |
2928 | 233 |
234 return retval; | |
235 } | |
236 | |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
237 /* |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
238 |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
239 %!test |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
240 %! ts = localtime (time ()); |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
241 %! assert((isstruct (ts) |
10231
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
242 %! && isfield (ts, "usec") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
243 %! && isfield (ts, "year") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
244 %! && isfield (ts, "mon") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
245 %! && isfield (ts, "mday") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
246 %! && isfield (ts, "sec") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
247 %! && isfield (ts, "min") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
248 %! && isfield (ts, "wday") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
249 %! && isfield (ts, "hour") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
250 %! && isfield (ts, "isdst") |
f63ee6a20f57
Replace removed functions in tests
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
10155
diff
changeset
|
251 %! && isfield (ts, "yday"))); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
252 |
13915
5fa482628bf6
Remove unnecessary regular expression '.*' from ends of %!error blocks
Rik <octave@nomad.inbox5.com>
parents:
12776
diff
changeset
|
253 %!error <Invalid call to localtime> localtime (); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
254 |
13915
5fa482628bf6
Remove unnecessary regular expression '.*' from ends of %!error blocks
Rik <octave@nomad.inbox5.com>
parents:
12776
diff
changeset
|
255 %!error <Invalid call to localtime> localtime (1, 2); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
256 |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
257 */ |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
258 |
2928 | 259 DEFUN_DLD (mktime, args, , |
3301 | 260 "-*- texinfo -*-\n\ |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
261 @deftypefn {Loadable Function} {@var{seconds} =} mktime (@var{tm_struct})\n\ |
3301 | 262 Convert a time structure corresponding to the local time to the number\n\ |
10840 | 263 of seconds since the epoch. For example:\n\ |
3301 | 264 \n\ |
265 @example\n\ | |
266 @group\n\ | |
7097 | 267 mktime (localtime (time ()))\n\ |
3301 | 268 @result{} 856163706\n\ |
269 @end group\n\ | |
270 @end example\n\ | |
5688 | 271 @seealso{strftime, strptime, localtime, gmtime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\ |
3301 | 272 @end deftypefn") |
2928 | 273 { |
3465 | 274 octave_value retval; |
2928 | 275 |
3254 | 276 if (args.length () == 1) |
2928 | 277 { |
11042
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
278 octave_scalar_map map = args(0).scalar_map_value (); |
2928 | 279 |
3254 | 280 if (! error_state) |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
281 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
282 octave_base_tm tm = extract_tm (map); |
3254 | 283 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
284 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
285 retval = octave_time (tm); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
286 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
287 error ("mktime: invalid TM_STRUCT argument"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
288 } |
3254 | 289 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
290 error ("mktime: TM_STRUCT argument must be a structure"); |
2928 | 291 } |
292 else | |
5823 | 293 print_usage (); |
2928 | 294 |
295 return retval; | |
296 } | |
297 | |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
298 /* |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
299 |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
300 %!test |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
301 %! t = time (); |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
302 %! assert(fix (mktime (localtime (t))) == fix (t)); |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
303 |
13915
5fa482628bf6
Remove unnecessary regular expression '.*' from ends of %!error blocks
Rik <octave@nomad.inbox5.com>
parents:
12776
diff
changeset
|
304 %!error <Invalid call to mktime> mktime (); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
305 |
13915
5fa482628bf6
Remove unnecessary regular expression '.*' from ends of %!error blocks
Rik <octave@nomad.inbox5.com>
parents:
12776
diff
changeset
|
306 %!error <Invalid call to mktime> mktime (1, 2, 3); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
307 |
11005
0de4eff677d6
use mktime module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
308 %% These tests fail on systems with mktime functions of limited |
0de4eff677d6
use mktime module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
309 %% intelligence: |
0de4eff677d6
use mktime module from gnulib
John W. Eaton <jwe@octave.org>
parents:
10840
diff
changeset
|
310 %!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
|
311 %!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
|
312 %!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
|
313 |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
314 */ |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
315 |
2928 | 316 DEFUN_DLD (strftime, args, , |
3295 | 317 "-*- texinfo -*-\n\ |
5675 | 318 @deftypefn {Loadable Function} {} strftime (@var{fmt}, @var{tm_struct})\n\ |
319 Format the time structure @var{tm_struct} in a flexible way using the\n\ | |
320 format string @var{fmt} that contains @samp{%} substitutions\n\ | |
3295 | 321 similar to those in @code{printf}. Except where noted, substituted\n\ |
322 fields have a fixed size; numeric fields are padded if necessary.\n\ | |
323 Padding is with zeros by default; for fields that display a single\n\ | |
324 number, padding can be changed or inhibited by following the @samp{%}\n\ | |
325 with one of the modifiers described below. Unknown field specifiers are\n\ | |
326 copied as normal characters. All other characters are copied to the\n\ | |
10840 | 327 output without change. For example:\n\ |
2928 | 328 \n\ |
3295 | 329 @example\n\ |
330 @group\n\ | |
5020 | 331 strftime (\"%r (%Z) %A %e %B %Y\", localtime (time ()))\n\ |
14360
97883071e8e4
doc: Correct off-by-1 spacings in all .cc docstrings
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
332 @result{} \"01:15:06 AM (CST) Monday 17 February 1997\"\n\ |
3295 | 333 @end group\n\ |
334 @end example\n\ | |
2928 | 335 \n\ |
3295 | 336 Octave's @code{strftime} function supports a superset of the ANSI C\n\ |
337 field specifiers.\n\ | |
2928 | 338 \n\ |
3295 | 339 @noindent\n\ |
2928 | 340 Literal character fields:\n\ |
341 \n\ | |
3295 | 342 @table @code\n\ |
12776
944cf42c699e
doc: small documentation fixes for strftime, betainc
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
343 @item %%\n\ |
3295 | 344 % character.\n\ |
2928 | 345 \n\ |
12776
944cf42c699e
doc: small documentation fixes for strftime, betainc
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
346 @item %n\n\ |
3295 | 347 Newline character.\n\ |
348 \n\ | |
12776
944cf42c699e
doc: small documentation fixes for strftime, betainc
Rik <octave@nomad.inbox5.com>
parents:
12642
diff
changeset
|
349 @item %t\n\ |
3295 | 350 Tab character.\n\ |
351 @end table\n\ | |
352 \n\ | |
353 @noindent\n\ | |
2928 | 354 Numeric modifiers (a nonstandard extension):\n\ |
355 \n\ | |
3295 | 356 @table @code\n\ |
357 @item - (dash)\n\ | |
358 Do not pad the field.\n\ | |
2928 | 359 \n\ |
3295 | 360 @item _ (underscore)\n\ |
361 Pad the field with spaces.\n\ | |
362 @end table\n\ | |
363 \n\ | |
364 @noindent\n\ | |
2928 | 365 Time fields:\n\ |
366 \n\ | |
3295 | 367 @table @code\n\ |
368 @item %H\n\ | |
369 Hour (00-23).\n\ | |
370 \n\ | |
371 @item %I\n\ | |
372 Hour (01-12).\n\ | |
373 \n\ | |
374 @item %k\n\ | |
375 Hour (0-23).\n\ | |
376 \n\ | |
377 @item %l\n\ | |
378 Hour (1-12).\n\ | |
379 \n\ | |
380 @item %M\n\ | |
381 Minute (00-59).\n\ | |
382 \n\ | |
383 @item %p\n\ | |
384 Locale's AM or PM.\n\ | |
2928 | 385 \n\ |
3295 | 386 @item %r\n\ |
387 Time, 12-hour (hh:mm:ss [AP]M).\n\ | |
388 \n\ | |
389 @item %R\n\ | |
390 Time, 24-hour (hh:mm).\n\ | |
391 \n\ | |
392 @item %s\n\ | |
393 Time in seconds since 00:00:00, Jan 1, 1970 (a nonstandard extension).\n\ | |
394 \n\ | |
395 @item %S\n\ | |
396 Second (00-61).\n\ | |
397 \n\ | |
398 @item %T\n\ | |
399 Time, 24-hour (hh:mm:ss).\n\ | |
400 \n\ | |
401 @item %X\n\ | |
402 Locale's time representation (%H:%M:%S).\n\ | |
403 \n\ | |
404 @item %Z\n\ | |
405 Time zone (EDT), or nothing if no time zone is determinable.\n\ | |
406 @end table\n\ | |
407 \n\ | |
408 @noindent\n\ | |
2928 | 409 Date fields:\n\ |
410 \n\ | |
3295 | 411 @table @code\n\ |
412 @item %a\n\ | |
413 Locale's abbreviated weekday name (Sun-Sat).\n\ | |
414 \n\ | |
415 @item %A\n\ | |
416 Locale's full weekday name, variable length (Sunday-Saturday).\n\ | |
417 \n\ | |
418 @item %b\n\ | |
419 Locale's abbreviated month name (Jan-Dec).\n\ | |
420 \n\ | |
421 @item %B\n\ | |
422 Locale's full month name, variable length (January-December).\n\ | |
423 \n\ | |
424 @item %c\n\ | |
425 Locale's date and time (Sat Nov 04 12:02:33 EST 1989).\n\ | |
426 \n\ | |
427 @item %C\n\ | |
428 Century (00-99).\n\ | |
429 \n\ | |
430 @item %d\n\ | |
431 Day of month (01-31).\n\ | |
432 \n\ | |
433 @item %e\n\ | |
434 Day of month ( 1-31).\n\ | |
435 \n\ | |
436 @item %D\n\ | |
437 Date (mm/dd/yy).\n\ | |
438 \n\ | |
439 @item %h\n\ | |
440 Same as %b.\n\ | |
441 \n\ | |
442 @item %j\n\ | |
443 Day of year (001-366).\n\ | |
444 \n\ | |
445 @item %m\n\ | |
446 Month (01-12).\n\ | |
447 \n\ | |
448 @item %U\n\ | |
449 Week number of year with Sunday as first day of week (00-53).\n\ | |
450 \n\ | |
451 @item %w\n\ | |
452 Day of week (0-6).\n\ | |
453 \n\ | |
454 @item %W\n\ | |
455 Week number of year with Monday as first day of week (00-53).\n\ | |
456 \n\ | |
457 @item %x\n\ | |
458 Locale's date representation (mm/dd/yy).\n\ | |
459 \n\ | |
460 @item %y\n\ | |
461 Last two digits of year (00-99).\n\ | |
462 \n\ | |
463 @item %Y\n\ | |
464 Year (1970-).\n\ | |
465 @end table\n\ | |
5688 | 466 @seealso{strptime, localtime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\ |
5646 | 467 @end deftypefn") |
2928 | 468 { |
3465 | 469 octave_value retval; |
2928 | 470 |
3254 | 471 if (args.length () == 2) |
2928 | 472 { |
3523 | 473 std::string fmt = args(0).string_value (); |
2928 | 474 |
475 if (! error_state) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
476 { |
11042
f6b7b6e5b8b8
time.cc: use octave_scalar_map instead of Octave_map
John W. Eaton <jwe@octave.org>
parents:
11005
diff
changeset
|
477 octave_scalar_map map = args(1).scalar_map_value (); |
2928 | 478 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
479 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
480 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
481 octave_base_tm tm = extract_tm (map); |
3233 | 482 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
483 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
484 retval = tm.strftime (fmt); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
485 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
486 error ("strftime: invalid TM_STRUCT argument"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
487 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
488 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
489 error ("strftime: TM_STRUCT must be a structure"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
490 } |
3254 | 491 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
492 error ("strftime: FMT must be a string"); |
2928 | 493 } |
494 else | |
5823 | 495 print_usage (); |
2928 | 496 |
497 return retval; | |
498 } | |
499 | |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
500 /* |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
501 |
7768
a2d9f325b65a
Use isschar instead of deprecated isstr
Rafael Laboissiere <rafael@debian.org>
parents:
7562
diff
changeset
|
502 %!assert((ischar (strftime ("%%%n%t%H%I%k%l", localtime (time ()))) |
a2d9f325b65a
Use isschar instead of deprecated isstr
Rafael Laboissiere <rafael@debian.org>
parents:
7562
diff
changeset
|
503 %! && ischar (strftime ("%M%p%r%R%s%S%T", localtime (time ()))) |
a2d9f325b65a
Use isschar instead of deprecated isstr
Rafael Laboissiere <rafael@debian.org>
parents:
7562
diff
changeset
|
504 %! && ischar (strftime ("%X%Z%z%a%A%b%B", localtime (time ()))) |
a2d9f325b65a
Use isschar instead of deprecated isstr
Rafael Laboissiere <rafael@debian.org>
parents:
7562
diff
changeset
|
505 %! && ischar (strftime ("%c%C%d%e%D%h%j", localtime (time ()))) |
a2d9f325b65a
Use isschar instead of deprecated isstr
Rafael Laboissiere <rafael@debian.org>
parents:
7562
diff
changeset
|
506 %! && 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
|
507 |
13915
5fa482628bf6
Remove unnecessary regular expression '.*' from ends of %!error blocks
Rik <octave@nomad.inbox5.com>
parents:
12776
diff
changeset
|
508 %!error <Invalid call to strftime> strftime (); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
509 |
13915
5fa482628bf6
Remove unnecessary regular expression '.*' from ends of %!error blocks
Rik <octave@nomad.inbox5.com>
parents:
12776
diff
changeset
|
510 %!error <Invalid call to strftime> strftime ("foo", localtime (time ()), 1); |
7562
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
511 |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
512 */ |
c827f5673321
move tests to individual source files
John W. Eaton <jwe@octave.org>
parents:
7097
diff
changeset
|
513 |
3465 | 514 DEFUN_DLD (strptime, args, , |
515 "-*- texinfo -*-\n\ | |
4367 | 516 @deftypefn {Loadable Function} {[@var{tm_struct}, @var{nchars}] =} strptime (@var{str}, @var{fmt})\n\ |
5675 | 517 Convert the string @var{str} to the time structure @var{tm_struct} under\n\ |
518 the control of the format string @var{fmt}.\n\ | |
519 \n\ | |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
520 If @var{fmt} fails to match, @var{nchars} is 0; otherwise, it is set to the\n\ |
5675 | 521 position of last matched character plus 1. Always check for this unless\n\ |
522 you're absolutely sure the date string will be parsed correctly.\n\ | |
5688 | 523 @seealso{strftime, localtime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}\n\ |
3465 | 524 @end deftypefn") |
525 { | |
526 octave_value_list retval; | |
527 | |
528 if (args.length () == 2) | |
529 { | |
3523 | 530 std::string str = args(0).string_value (); |
3465 | 531 |
532 if (! error_state) | |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
533 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
534 std::string fmt = args(1).string_value (); |
3465 | 535 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
536 if (! error_state) |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
537 { |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
538 octave_strptime t (str, fmt); |
3465 | 539 |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
540 retval(1) = t.characters_converted (); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
541 retval(0) = octave_value (mk_tm_map (t)); |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
542 } |
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
543 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
544 error ("strptime: FMT must be a string"); |
10154
40dfc0c99116
DLD-FUNCTIONS/*.cc: untabify
John W. Eaton <jwe@octave.org>
parents:
9209
diff
changeset
|
545 } |
3465 | 546 else |
11553
01f703952eff
Improve docstrings for functions in DLD-FUNCTIONS directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
547 error ("strptime: argument STR must be a string"); |
3465 | 548 } |
549 else | |
5823 | 550 print_usage (); |
3465 | 551 |
552 return retval; | |
553 } |