annotate scripts/time/datevec.m @ 19627:446c46af4b42 stable

strip trailing whitespace from most source files * Makefile.am, NEWS, build-aux/common.mk, configure.ac, doc/Makefile.am, doc/doxyhtml/Makefile.am, doc/interpreter/Makefile.am, doc/interpreter/arith.txi, doc/interpreter/audio.txi, doc/interpreter/basics.txi, doc/interpreter/bugs.txi, doc/interpreter/container.txi, doc/interpreter/cp-idx.txi, doc/interpreter/data.txi, doc/interpreter/debug.txi, doc/interpreter/diagperm.txi, doc/interpreter/diffeq.txi, doc/interpreter/doccheck/README, doc/interpreter/doccheck/spellcheck, doc/interpreter/emacs.txi, doc/interpreter/errors.txi, doc/interpreter/eval.txi, doc/interpreter/expr.txi, doc/interpreter/external.txi, doc/interpreter/fn-idx.txi, doc/interpreter/func.txi, doc/interpreter/geometry.txi, doc/interpreter/geometryimages.m, doc/interpreter/gpl.txi, doc/interpreter/grammar.txi, doc/interpreter/gui.txi, doc/interpreter/image.txi, doc/interpreter/install.txi, doc/interpreter/interp.txi, doc/interpreter/interpimages.m, doc/interpreter/intro.txi, doc/interpreter/io.txi, doc/interpreter/java.txi, doc/interpreter/linalg.txi, doc/interpreter/macros.texi, doc/interpreter/matrix.txi, doc/interpreter/munge-texi.pl, doc/interpreter/nonlin.txi, doc/interpreter/numbers.txi, doc/interpreter/obsolete.txi, doc/interpreter/octave-config.1, doc/interpreter/octave.texi, doc/interpreter/oop.txi, doc/interpreter/op-idx.txi, doc/interpreter/optim.txi, doc/interpreter/package.txi, doc/interpreter/plot.txi, doc/interpreter/poly.txi, doc/interpreter/preface.txi, doc/interpreter/quad.txi, doc/interpreter/set.txi, doc/interpreter/signal.txi, doc/interpreter/sparse.txi, doc/interpreter/sparseimages.m, doc/interpreter/splineimages.m, doc/interpreter/stats.txi, doc/interpreter/stmt.txi, doc/interpreter/strings.txi, doc/interpreter/system.txi, doc/interpreter/testfun.txi, doc/interpreter/tips.txi, doc/interpreter/var.txi, doc/interpreter/vectorize.txi, doc/liboctave/Makefile.am, doc/liboctave/array.texi, doc/liboctave/bugs.texi, doc/liboctave/cp-idx.texi, doc/liboctave/dae.texi, doc/liboctave/diffeq.texi, doc/liboctave/error.texi, doc/liboctave/factor.texi, doc/liboctave/fn-idx.texi, doc/liboctave/gpl.texi, doc/liboctave/install.texi, doc/liboctave/intro.texi, doc/liboctave/liboctave.texi, doc/liboctave/matvec.texi, doc/liboctave/nleqn.texi, doc/liboctave/nlfunc.texi, doc/liboctave/ode.texi, doc/liboctave/optim.texi, doc/liboctave/preface.texi, doc/liboctave/quad.texi, doc/liboctave/range.texi, doc/refcard/Makefile.am, doc/refcard/refcard.tex, etc/HACKING, etc/NEWS.1, etc/NEWS.2, etc/NEWS.3, etc/OLD-ChangeLogs/ChangeLog, etc/OLD-ChangeLogs/doc-ChangeLog, etc/OLD-ChangeLogs/scripts-ChangeLog, etc/OLD-ChangeLogs/src-ChangeLog, etc/OLD-ChangeLogs/test-ChangeLog, etc/PROJECTS, etc/README.Cygwin, etc/README.MacOS, etc/README.MinGW, etc/README.gnuplot, etc/gdbinit, etc/icons/Makefile.am, examples/@polynomial/end.m, examples/@polynomial/subsasgn.m, examples/Makefile.am, examples/standalonebuiltin.cc, libgui/Makefile.am, libgui/qterminal/libqterminal/README, libgui/qterminal/libqterminal/unix/BlockArray.cpp, libgui/qterminal/libqterminal/unix/BlockArray.h, libgui/qterminal/libqterminal/unix/Character.h, libgui/qterminal/libqterminal/unix/CharacterColor.h, libgui/qterminal/libqterminal/unix/Emulation.cpp, libgui/qterminal/libqterminal/unix/Emulation.h, libgui/qterminal/libqterminal/unix/Filter.cpp, libgui/qterminal/libqterminal/unix/Filter.h, libgui/qterminal/libqterminal/unix/History.cpp, libgui/qterminal/libqterminal/unix/History.h, libgui/qterminal/libqterminal/unix/KeyboardTranslator.cpp, libgui/qterminal/libqterminal/unix/KeyboardTranslator.h, libgui/qterminal/libqterminal/unix/LineFont.h, libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp, libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h, libgui/qterminal/libqterminal/unix/Screen.cpp, libgui/qterminal/libqterminal/unix/Screen.h, libgui/qterminal/libqterminal/unix/ScreenWindow.cpp, libgui/qterminal/libqterminal/unix/ScreenWindow.h, libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.cpp, libgui/qterminal/libqterminal/unix/TerminalCharacterDecoder.h, libgui/qterminal/libqterminal/unix/Vt102Emulation.h, libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp, libgui/qterminal/qterminal/main.cpp, libgui/src/m-editor/file-editor-tab.cc, libgui/src/octave-gui.cc, libgui/src/octave-qt-link.cc, libinterp/corefcn/data.cc, libinterp/corefcn/defun-int.h, libinterp/corefcn/det.cc, libinterp/corefcn/gl2ps-renderer.cc, libinterp/corefcn/graphics.cc, libinterp/corefcn/graphics.in.h, libinterp/corefcn/ls-mat5.cc, libinterp/corefcn/lu.cc, libinterp/corefcn/oct-tex-parser.yy, libinterp/corefcn/oct-tex-symbols.in, libinterp/corefcn/quadcc.cc, libinterp/corefcn/zfstream.cc, libinterp/dldfcn/__eigs__.cc, libinterp/dldfcn/__voronoi__.cc, libinterp/gendoc.pl, libinterp/genprops.awk, libinterp/mk-errno-list, libinterp/mk-pkg-add, libinterp/mkbuiltins, libinterp/mkdefs, libinterp/mkdocs, libinterp/mkops, libinterp/octave-value/ov-java.cc, libinterp/parse-tree/lex.ll, libinterp/parse-tree/oct-parse.in.yy, libinterp/parse-tree/octave.gperf, liboctave/Makefile.am, liboctave/array/Array.cc, liboctave/array/module.mk, liboctave/cruft/daspk/datv.f, liboctave/cruft/daspk/dcnst0.f, liboctave/cruft/daspk/dcnstr.f, liboctave/cruft/daspk/ddasic.f, liboctave/cruft/daspk/ddasid.f, liboctave/cruft/daspk/ddasik.f, liboctave/cruft/daspk/ddaspk.f, liboctave/cruft/daspk/ddstp.f, liboctave/cruft/daspk/ddwnrm.f, liboctave/cruft/daspk/dfnrmd.f, liboctave/cruft/daspk/dfnrmk.f, liboctave/cruft/daspk/dhels.f, liboctave/cruft/daspk/dheqr.f, liboctave/cruft/daspk/dinvwt.f, liboctave/cruft/daspk/dlinsd.f, liboctave/cruft/daspk/dlinsk.f, liboctave/cruft/daspk/dmatd.f, liboctave/cruft/daspk/dnedd.f, liboctave/cruft/daspk/dnedk.f, liboctave/cruft/daspk/dnsd.f, liboctave/cruft/daspk/dnsid.f, liboctave/cruft/daspk/dnsik.f, liboctave/cruft/daspk/dnsk.f, liboctave/cruft/daspk/dorth.f, liboctave/cruft/daspk/dslvd.f, liboctave/cruft/daspk/dslvk.f, liboctave/cruft/daspk/dspigm.f, liboctave/cruft/daspk/dyypnw.f, liboctave/cruft/dasrt/ddasrt.f, liboctave/cruft/dasrt/drchek.f, liboctave/cruft/dassl/ddaslv.f, liboctave/cruft/dassl/ddassl.f, liboctave/cruft/misc/blaswrap.c, liboctave/cruft/misc/module.mk, liboctave/cruft/odepack/cfode.f, liboctave/cruft/odepack/dlsode.f, liboctave/cruft/odepack/ewset.f, liboctave/cruft/odepack/intdy.f, liboctave/cruft/odepack/prepj.f, liboctave/cruft/odepack/sintdy.f, liboctave/cruft/odepack/slsode.f, liboctave/cruft/odepack/solsy.f, liboctave/cruft/odepack/ssolsy.f, liboctave/cruft/odepack/stode.f, liboctave/cruft/odepack/vnorm.f, liboctave/cruft/ranlib/Basegen.doc, liboctave/cruft/ranlib/README, liboctave/cruft/ranlib/genbet.f, liboctave/cruft/ranlib/genexp.f, liboctave/cruft/ranlib/gennch.f, liboctave/cruft/ranlib/gennf.f, liboctave/cruft/ranlib/gennor.f, liboctave/cruft/ranlib/getsd.f, liboctave/cruft/ranlib/initgn.f, liboctave/cruft/ranlib/phrtsd.f, liboctave/cruft/ranlib/randlib.fdoc, liboctave/cruft/ranlib/setsd.f, liboctave/cruft/ranlib/tstgmn.for, liboctave/cruft/ranlib/tstmid.for, liboctave/cruft/slatec-fn/atanh.f, liboctave/cruft/slatec-fn/datanh.f, liboctave/cruft/slatec-fn/xgmainc.f, liboctave/cruft/slatec-fn/xsgmainc.f, liboctave/numeric/module.mk, liboctave/operators/mk-ops.awk, liboctave/operators/mx-ops, liboctave/operators/sparse-mk-ops.awk, liboctave/operators/sparse-mx-ops, liboctave/operators/vx-ops, liboctave/util/module.mk, run-octave.in, scripts/@ftp/ftp.m, scripts/audio/wavread.m, scripts/deprecated/java_convert_matrix.m, scripts/deprecated/java_debug.m, scripts/deprecated/java_invoke.m, scripts/deprecated/java_new.m, scripts/deprecated/java_unsigned_conversion.m, scripts/deprecated/javafields.m, scripts/deprecated/javamethods.m, scripts/deprecated/shell_cmd.m, scripts/general/accumarray.m, scripts/general/display.m, scripts/general/fieldnames.m, scripts/general/interp1.m, scripts/general/interp2.m, scripts/general/interp3.m, scripts/general/isa.m, scripts/general/methods.m, scripts/general/sortrows.m, scripts/geometry/convhull.m, scripts/geometry/delaunay.m, scripts/geometry/delaunay3.m, scripts/geometry/delaunayn.m, scripts/geometry/griddata.m, scripts/geometry/griddatan.m, scripts/geometry/voronoi.m, scripts/geometry/voronoin.m, scripts/gui/guihandles.m, scripts/gui/inputdlg.m, scripts/gui/listdlg.m, scripts/gui/msgbox.m, scripts/gui/questdlg.m, scripts/gui/uigetfile.m, scripts/gui/waitbar.m, scripts/gui/warndlg.m, scripts/help/doc.m, scripts/help/help.m, scripts/help/type.m, scripts/image/bone.m, scripts/image/cmpermute.m, scripts/image/cmunique.m, scripts/image/colorcube.m, scripts/image/colormap.m, scripts/image/contrast.m, scripts/image/gray2ind.m, scripts/image/image.m, scripts/image/imshow.m, scripts/image/ind2gray.m, scripts/image/jet.m, scripts/image/rgb2ntsc.m, scripts/image/spinmap.m, scripts/io/importdata.m, scripts/io/strread.m, scripts/io/textread.m, scripts/io/textscan.m, scripts/java/java_get.m, scripts/java/java_set.m, scripts/java/javaaddpath.m, scripts/java/javaclasspath.m, scripts/java/javamem.m, scripts/linear-algebra/linsolve.m, scripts/linear-algebra/qzhess.m, scripts/miscellaneous/debug.m, scripts/miscellaneous/desktop.m, scripts/miscellaneous/dir.m, scripts/miscellaneous/dos.m, scripts/miscellaneous/edit.m, scripts/miscellaneous/fact.m, scripts/miscellaneous/getappdata.m, scripts/miscellaneous/inputname.m, scripts/miscellaneous/license.m, scripts/miscellaneous/ls_command.m, scripts/miscellaneous/run.m, scripts/miscellaneous/setfield.m, scripts/miscellaneous/unix.m, scripts/miscellaneous/ver.m, scripts/mk-pkg-add, scripts/mkdoc.pl, scripts/optimization/fminsearch.m, scripts/optimization/optimset.m, scripts/optimization/sqp.m, scripts/pkg/pkg.m, scripts/pkg/private/create_pkgadddel.m, scripts/pkg/private/fix_depends.m, scripts/pkg/private/install.m, scripts/plot/appearance/axis.m, scripts/plot/appearance/box.m, scripts/plot/appearance/clabel.m, scripts/plot/appearance/daspect.m, scripts/plot/appearance/datetick.m, scripts/plot/appearance/grid.m, scripts/plot/appearance/legend.m, scripts/plot/appearance/orient.m, scripts/plot/appearance/shading.m, scripts/plot/appearance/text.m, scripts/plot/appearance/title.m, scripts/plot/appearance/xlabel.m, scripts/plot/appearance/ylabel.m, scripts/plot/appearance/zlabel.m, scripts/plot/draw/area.m, scripts/plot/draw/bar.m, scripts/plot/draw/barh.m, scripts/plot/draw/colorbar.m, scripts/plot/draw/contour.m, scripts/plot/draw/contour3.m, scripts/plot/draw/contourf.m, scripts/plot/draw/ellipsoid.m, scripts/plot/draw/errorbar.m, scripts/plot/draw/ezcontour.m, scripts/plot/draw/ezcontourf.m, scripts/plot/draw/ezmesh.m, scripts/plot/draw/ezpolar.m, scripts/plot/draw/fill.m, scripts/plot/draw/fplot.m, scripts/plot/draw/hist.m, scripts/plot/draw/meshc.m, scripts/plot/draw/meshz.m, scripts/plot/draw/pareto.m, scripts/plot/draw/patch.m, scripts/plot/draw/peaks.m, scripts/plot/draw/pie.m, scripts/plot/draw/pie3.m, scripts/plot/draw/plot.m, scripts/plot/draw/plotyy.m, scripts/plot/draw/private/__bar__.m, scripts/plot/draw/private/__contour__.m, scripts/plot/draw/private/__errplot__.m, scripts/plot/draw/private/__ezplot__.m, scripts/plot/draw/private/__patch__.m, scripts/plot/draw/private/__stem__.m, scripts/plot/draw/rectangle.m, scripts/plot/draw/ribbon.m, scripts/plot/draw/rose.m, scripts/plot/draw/scatter.m, scripts/plot/draw/scatter3.m, scripts/plot/draw/semilogx.m, scripts/plot/draw/shrinkfaces.m, scripts/plot/draw/sombrero.m, scripts/plot/draw/sphere.m, scripts/plot/draw/stairs.m, scripts/plot/draw/stem.m, scripts/plot/draw/stemleaf.m, scripts/plot/draw/surf.m, scripts/plot/draw/surface.m, scripts/plot/draw/surfc.m, scripts/plot/draw/surfl.m, scripts/plot/draw/surfnorm.m, scripts/plot/draw/tetramesh.m, scripts/plot/draw/trimesh.m, scripts/plot/draw/triplot.m, scripts/plot/draw/trisurf.m, scripts/plot/util/__gnuplot_drawnow__.m, scripts/plot/util/__plt_get_axis_arg__.m, scripts/plot/util/axes.m, scripts/plot/util/clf.m, scripts/plot/util/copyobj.m, scripts/plot/util/figure.m, scripts/plot/util/gcbo.m, scripts/plot/util/graphics_toolkit.m, scripts/plot/util/hggroup.m, scripts/plot/util/meshgrid.m, scripts/plot/util/newplot.m, scripts/plot/util/print.m, scripts/plot/util/private/__add_default_menu__.m, scripts/plot/util/private/__fltk_print__.m, scripts/plot/util/private/__gnuplot_print__.m, scripts/plot/util/private/__print_parse_opts__.m, scripts/plot/util/refreshdata.m, scripts/plot/util/subplot.m, scripts/polynomial/conv.m, scripts/polynomial/poly.m, scripts/polynomial/polyeig.m, scripts/polynomial/polyfit.m, scripts/polynomial/polyval.m, scripts/polynomial/private/__splinefit__.m, scripts/polynomial/spline.m, scripts/prefs/prefdir.m, scripts/prefs/preferences.m, scripts/prefs/private/prefsfile.m, scripts/prefs/rmpref.m, scripts/signal/freqz.m, scripts/signal/module.mk, scripts/sparse/eigs.m, scripts/sparse/pcg.m, scripts/sparse/private/__sprand_impl__.m, scripts/sparse/sprand.m, scripts/sparse/sprandn.m, scripts/sparse/spy.m, scripts/sparse/svds.m, scripts/specfun/expint.m, scripts/specfun/factor.m, scripts/special-matrix/gallery.m, scripts/special-matrix/hankel.m, scripts/special-matrix/toeplitz.m, scripts/startup/inputrc, scripts/statistics/base/kurtosis.m, scripts/statistics/base/moment.m, scripts/statistics/base/qqplot.m, scripts/statistics/base/var.m, scripts/statistics/distributions/betarnd.m, scripts/statistics/distributions/binoinv.m, scripts/statistics/distributions/binopdf.m, scripts/statistics/distributions/binornd.m, scripts/statistics/distributions/cauchy_rnd.m, scripts/statistics/distributions/chi2rnd.m, scripts/statistics/distributions/discrete_pdf.m, scripts/statistics/distributions/discrete_rnd.m, scripts/statistics/distributions/empirical_rnd.m, scripts/statistics/distributions/exprnd.m, scripts/statistics/distributions/frnd.m, scripts/statistics/distributions/gamrnd.m, scripts/statistics/distributions/geornd.m, scripts/statistics/distributions/hygernd.m, scripts/statistics/distributions/kolmogorov_smirnov_cdf.m, scripts/statistics/distributions/laplace_cdf.m, scripts/statistics/distributions/laplace_pdf.m, scripts/statistics/distributions/logistic_cdf.m, scripts/statistics/distributions/logistic_pdf.m, scripts/statistics/distributions/lognrnd.m, scripts/statistics/distributions/nbincdf.m, scripts/statistics/distributions/nbininv.m, scripts/statistics/distributions/nbinpdf.m, scripts/statistics/distributions/nbinrnd.m, scripts/statistics/distributions/normrnd.m, scripts/statistics/distributions/poissinv.m, scripts/statistics/distributions/poissrnd.m, scripts/statistics/distributions/tinv.m, scripts/statistics/distributions/trnd.m, scripts/statistics/distributions/unidcdf.m, scripts/statistics/distributions/unidpdf.m, scripts/statistics/distributions/unidrnd.m, scripts/statistics/distributions/unifrnd.m, scripts/statistics/distributions/wblrnd.m, scripts/statistics/models/module.mk, scripts/statistics/tests/kruskal_wallis_test.m, scripts/strings/base2dec.m, scripts/strings/deblank.m, scripts/strings/dec2base.m, scripts/strings/dec2bin.m, scripts/strings/dec2hex.m, scripts/strings/mat2str.m, scripts/strings/ostrsplit.m, scripts/strings/regexptranslate.m, scripts/strings/str2num.m, scripts/strings/strcat.m, scripts/strings/strjoin.m, scripts/strings/strsplit.m, scripts/strings/strtok.m, scripts/strings/strtrim.m, scripts/strings/strtrunc.m, scripts/strings/substr.m, scripts/testfun/__run_test_suite__.m, scripts/testfun/speed.m, scripts/testfun/test.m, scripts/time/asctime.m, scripts/time/datenum.m, scripts/time/datevec.m, scripts/time/weekday.m, src/Makefile.am, test/Makefile.am, test/build-bc-overload-tests.sh, test/build-sparse-tests.sh, test/jit.tst, test/line-continue.tst: Strip trailing whitespace.
author John W. Eaton <jwe@octave.org>
date Tue, 20 Jan 2015 08:26:57 -0500
parents 7d272300a880
children 0e1f5a750d00
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
17744
d63878346099 maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents: 14852
diff changeset
1 ## Copyright (C) 2000-2013 Paul Kienzle
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
2 ##
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
4 ##
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
8 ## your option) any later version.
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
9 ##
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
14 ##
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
17 ## <http://www.gnu.org/licenses/>.
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
18
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 9051
diff changeset
20 ## @deftypefn {Function File} {@var{v} =} datevec (@var{date})
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
21 ## @deftypefnx {Function File} {@var{v} =} datevec (@var{date}, @var{f})
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
22 ## @deftypefnx {Function File} {@var{v} =} datevec (@var{date}, @var{p})
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
23 ## @deftypefnx {Function File} {@var{v} =} datevec (@var{date}, @var{f}, @var{p})
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
24 ## @deftypefnx {Function File} {[@var{y}, @var{m}, @var{d}, @var{h}, @var{mi}, @var{s}] =} datevec (@dots{})
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
25 ## Convert a serial date number (see @code{datenum}) or date string (see
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
26 ## @code{datestr}) into a date vector.
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
27 ##
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
28 ## A date vector is a row vector with six members, representing the year,
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
29 ## month, day, hour, minute, and seconds respectively.
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
30 ##
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
31 ## @var{f} is the format string used to interpret date strings
14743
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
32 ## (see @code{datestr}). If @var{date} is a string, but no format is
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
33 ## specified, then a relatively slow search is performed through various
14852
53d2c3598d33 doc: Periodic spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents: 14743
diff changeset
34 ## formats. It is always preferable to specify the format string @var{f}
14743
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
35 ## if it is known. Formats which do not specify a particular time component
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
36 ## will have the value set to zero. Formats which do not specify a date will
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
37 ## default to January 1st of the current year.
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
38 ##
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
39 ## @var{p} is the year at the start of the century to which two-digit years
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
40 ## will be referenced. If not specified, it defaults to the current year
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
41 ## minus 50.
13856
d490ca8ab1a5 Modernize function implementations and docstrings in scripts/time.
Rik <octave@nomad.inbox5.com>
parents: 13848
diff changeset
42 ## @seealso{datenum, datestr, clock, now, date}
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
43 ## @end deftypefn
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
44
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
45 ## Algorithm: Peter Baum (http://vsg.cape.com/~pbaum/date/date0.htm)
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
46
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
47 ## Author: pkienzle <pkienzle@users.sf.net>
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
48 ## Modified: bdenney <bill@givebillmoney.com>
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
49 ## Created: 10 October 2001 (CVS)
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
50 ## Adapted-By: William Poetra Yoga Hadisoeseno <williampoetra@gmail.com>
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
51
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
52 ## The function __date_str2vec__ is based on datesplit by Bill Denney.
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
53
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
54 function [y, m, d, h, mi, s] = datevec (date, f = [], p = [])
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
55
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
56 persistent std_formats nfmt;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
57
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
58 if (isempty (std_formats))
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
59 std_formats = cell ();
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
60 nfmt = 0;
14743
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
61 ## These formats are specified by Matlab documentation to be parsed
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
62 ## The '# XX' refers to the datestr numerical format code
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
63 std_formats{++nfmt} = "dd-mmm-yyyy HH:MM:SS"; # 0
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
64 std_formats{++nfmt} = "dd-mmm-yyyy"; # 1
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
65 std_formats{++nfmt} = "mm/dd/yy"; # 2
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
66 std_formats{++nfmt} = "mm/dd"; # 6
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
67 std_formats{++nfmt} = "HH:MM:SS"; # 13
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
68 std_formats{++nfmt} = "HH:MM:SS PM"; # 14
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
69 std_formats{++nfmt} = "HH:MM"; # 15
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
70 std_formats{++nfmt} = "HH:MM PM"; # 16
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
71 std_formats{++nfmt} = "mm/dd/yyyy"; # 23
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
72
14743
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
73 ## These formats are undocumented but parsed by Matlab
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
74 std_formats{++nfmt} = "mmmyy"; # 12
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
75 std_formats{++nfmt} = "mmm.dd,yyyy HH:MM:SS"; # 21
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
76 std_formats{++nfmt} = "mmm.dd,yyyy"; # 22
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
77 std_formats{++nfmt} = "yyyy/mm/dd"; # 26
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
78 std_formats{++nfmt} = "yyyy-mm-dd"; # 29
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
79 std_formats{++nfmt} = "yyyy-mm-dd HH:MM:SS"; # 31
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
80
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
81 ## These are other formats that Octave tries
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
82 std_formats{++nfmt} = "mmm-dd-yyyy HH:MM:SS";
6044
12fd61d549ba [project @ 2006-10-09 21:28:23 by jwe]
jwe
parents: 5873
diff changeset
83 std_formats{++nfmt} = "mmm-dd-yyyy";
12fd61d549ba [project @ 2006-10-09 21:28:23 by jwe]
jwe
parents: 5873
diff changeset
84 std_formats{++nfmt} = "dd mmm yyyy HH:MM:SS";
12fd61d549ba [project @ 2006-10-09 21:28:23 by jwe]
jwe
parents: 5873
diff changeset
85 std_formats{++nfmt} = "dd mmm yyyy";
12fd61d549ba [project @ 2006-10-09 21:28:23 by jwe]
jwe
parents: 5873
diff changeset
86 std_formats{++nfmt} = "mmm dd yyyy HH:MM:SS";
12fd61d549ba [project @ 2006-10-09 21:28:23 by jwe]
jwe
parents: 5873
diff changeset
87 std_formats{++nfmt} = "mmm dd yyyy";
12fd61d549ba [project @ 2006-10-09 21:28:23 by jwe]
jwe
parents: 5873
diff changeset
88 std_formats{++nfmt} = "dd.mmm.yyyy HH:MM:SS";
12fd61d549ba [project @ 2006-10-09 21:28:23 by jwe]
jwe
parents: 5873
diff changeset
89 std_formats{++nfmt} = "dd.mmm.yyyy";
12fd61d549ba [project @ 2006-10-09 21:28:23 by jwe]
jwe
parents: 5873
diff changeset
90 std_formats{++nfmt} = "mmm.dd.yyyy HH:MM:SS";
12fd61d549ba [project @ 2006-10-09 21:28:23 by jwe]
jwe
parents: 5873
diff changeset
91 std_formats{++nfmt} = "mmm.dd.yyyy";
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
92 std_formats{++nfmt} = "mm/dd/yyyy HH:MM";
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
93 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
94
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
95 if (nargin < 1 || nargin > 3)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 6044
diff changeset
96 print_usage ();
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
97 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
98
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
99 if (ischar (date))
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
100 date = cellstr (date);
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
101 endif
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
102
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
103 if (isnumeric (f))
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
104 p = f;
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
105 f = [];
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
106 endif
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
107
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
108 if (isempty (f))
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
109 f = -1;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
110 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
111
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
112 if (isempty (p))
11400
277d891afae2 datevec.m: style fixes
John W. Eaton <jwe@octave.org>
parents: 11086
diff changeset
113 p = (localtime (time ())).year + 1900 - 50;
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
114 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
115
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
116 if (iscell (date))
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
117
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
118 nd = numel (date);
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
119
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
120 y = m = d = h = mi = s = zeros (nd, 1);
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
121
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
122 if (f == -1)
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
123 for k = 1:nd
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
124 found = false;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
125 for l = 1:nfmt
8411
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
126 [f, rY, ry, fy, fm, fd, fh, fmi, fs] = __date_vfmt2sfmt__ (std_formats{l});
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
127 [found y(k) m(k) d(k) h(k) mi(k) s(k)] = __date_str2vec__ (date{k}, p, f, rY, ry, fy, fm, fd, fh, fmi, fs);
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
128 if (found)
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
129 break;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
130 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
131 endfor
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
132 if (! found)
11472
1740012184f9 Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents: 11400
diff changeset
133 error ("datevec: none of the standard formats match the DATE string");
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
134 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
135 endfor
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
136 else
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
137 ## Decipher the format string just once for speed.
8411
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
138 [f, rY, ry, fy, fm, fd, fh, fmi, fs] = __date_vfmt2sfmt__ (f);
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
139 for k = 1:nd
8411
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
140 [found y(k) m(k) d(k) h(k) mi(k) s(k)] = __date_str2vec__ (date{k}, p, f, rY, ry, fy, fm, fd, fh, fmi, fs);
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
141 if (! found)
11472
1740012184f9 Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents: 11400
diff changeset
142 error ("datevec: DATE not parsed correctly with given format");
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
143 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
144 endfor
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
145 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
146
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
147 else # datenum input
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
148
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
149 date = date(:);
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
150
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
151 ## Move day 0 from midnight -0001-12-31 to midnight 0000-3-1
19418
7d272300a880 datevec.m: Fix negative number outputs with integer (non-float) inputs (bug #43753).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 17744
diff changeset
152 z = double (floor (date) - 60);
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
153 ## Calculate number of centuries; K1 = 0.25 is to avoid rounding problems.
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
154 a = floor ((z - 0.25) / 36524.25);
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
155 ## Days within century; K2 = 0.25 is to avoid rounding problems.
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
156 b = z - 0.25 + a - floor (a / 4);
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
157 ## Calculate the year (year starts on March 1).
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
158 y = floor (b / 365.25);
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
159 ## Calculate day in year.
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
160 c = fix (b - floor (365.25 * y)) + 1;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
161 ## Calculate month in year.
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
162 m = fix ((5 * c + 456) / 153);
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
163 d = c - fix ((153 * m - 457) / 5);
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
164 ## Move to Jan 1 as start of year.
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
165 ++y(m > 12);
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
166 m(m > 12) -= 12;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
167
5859
ba0bea22167b [project @ 2006-06-14 18:18:51 by jwe]
jwe
parents: 5687
diff changeset
168 ## Convert hour-minute-seconds. Attempt to account for precision of
ba0bea22167b [project @ 2006-06-14 18:18:51 by jwe]
jwe
parents: 5687
diff changeset
169 ## datenum format.
ba0bea22167b [project @ 2006-06-14 18:18:51 by jwe]
jwe
parents: 5687
diff changeset
170
ba0bea22167b [project @ 2006-06-14 18:18:51 by jwe]
jwe
parents: 5687
diff changeset
171 fracd = date - floor (date);
5873
b6ef36e92701 [project @ 2006-06-30 20:46:34 by jwe]
jwe
parents: 5860
diff changeset
172 tmps = abs (eps*86400*date);
b6ef36e92701 [project @ 2006-06-30 20:46:34 by jwe]
jwe
parents: 5860
diff changeset
173 tmps(tmps == 0) = 1;
b6ef36e92701 [project @ 2006-06-30 20:46:34 by jwe]
jwe
parents: 5860
diff changeset
174 srnd = 2 .^ floor (- log2 (tmps));
b6ef36e92701 [project @ 2006-06-30 20:46:34 by jwe]
jwe
parents: 5860
diff changeset
175 s = round (86400 * fracd .* srnd) ./ srnd;
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
176 h = floor (s / 3600);
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
177 s = s - 3600 * h;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
178 mi = floor (s / 60);
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
179 s = s - 60 * mi;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
180
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
181 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
182
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
183 if (nargout <= 1)
5873
b6ef36e92701 [project @ 2006-06-30 20:46:34 by jwe]
jwe
parents: 5860
diff changeset
184 y = [y, m, d, h, mi, s];
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
185 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
186
11086
af03ff97df7b datevec.m: use endfunction to mark end of primary function and subfunctions
John W. Eaton <jwe@octave.org>
parents: 10793
diff changeset
187 endfunction
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
188
8411
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
189 function [f, rY, ry, fy, fm, fd, fh, fmi, fs] = __date_vfmt2sfmt__ (f)
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
190
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8411
diff changeset
191 ## Play safe with percent signs.
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
192 f = strrep (f, "%", "%%");
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
193
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
194 if (! isempty (strfind (f, "PM")) || ! isempty (strfind (f, "AM")))
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
195 ampm = true;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
196 else
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
197 ampm = false;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
198 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
199
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8411
diff changeset
200 ## Date part.
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
201 f = regexprep (f, '[Yy][Yy][Yy][Yy]', "%Y");
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
202 f = regexprep (f, '[Yy][Yy]', "%y");
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
203 f = strrep (f, "mmmm", "%B");
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
204 f = strrep (f, "mmm", "%b");
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
205 f = strrep (f, "mm", "%m");
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
206 f = regexprep (f, '[Dd][Dd][Dd][Dd]', "%A");
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
207 f = regexprep (f, '[Dd][Dd][Dd]', "%a");
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
208 f = regexprep (f, '[Dd][Dd]', "%d");
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
209
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8411
diff changeset
210 ## Time part.
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
211 if (ampm)
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
212 f = strrep (f, "HH", "%I");
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
213 f = strrep (f, "PM", "%p");
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
214 f = strrep (f, "AM", "%p");
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
215 else
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
216 f = strrep (f, "HH", "%H");
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
217 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
218 f = strrep (f, "MM", "%M");
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
219 f = regexprep (f, '[Ss][Ss]', "%S");
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
220
8411
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
221 rY = rindex (f, "%Y");
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
222 ry = rindex (f, "%y");
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
223
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8411
diff changeset
224 ## Check whether we need to give default values.
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8411
diff changeset
225 ## Possible error when string contains "%%".
8411
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
226 fy = rY || ry;
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
227 fm = index (f, "%m") || index (f, "%b") || index (f, "%B");
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
228 fd = index (f, "%d") || index (f, "%a") || index (f, "%A");
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
229 fh = index (f, "%H") || index (f, "%I");
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
230 fmi = index (f, "%M");
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
231 fs = index (f, "%S");
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
232
11086
af03ff97df7b datevec.m: use endfunction to mark end of primary function and subfunctions
John W. Eaton <jwe@octave.org>
parents: 10793
diff changeset
233 endfunction
8411
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
234
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
235 function [found, y, m, d, h, mi, s] = __date_str2vec__ (ds, p, f, rY, ry, fy, fm, fd, fh, fmi, fs)
69d45a4c7d94 avoid repeated parsing of format string in datevec
Daniel J Sebald <daniel.sebald@ieee.org>
parents: 7044
diff changeset
236
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
237 idx = strfind (f, "FFF");
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19418
diff changeset
238 if (! isempty (idx))
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
239 ## Kludge to handle FFF millisecond format since strptime does not
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19418
diff changeset
240 f(idx:idx+2) = [];
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
241 [~, nc] = strptime (ds, f);
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
242 if (nc > 0)
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19418
diff changeset
243 msec = ds(nc:min(nc+2, end));
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19418
diff changeset
244 f = [f(1:idx-1) msec f(idx:end)];
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
245 [tm, nc] = strptime (ds, f);
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
246 tm.usec = 1000 * str2double (msec);
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
247 endif
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
248 else
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
249 [tm, nc] = strptime (ds, f);
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
250 endif
19627
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 19418
diff changeset
251
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
252 if (nc == columns (ds) + 1)
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
253 found = true;
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
254 y = tm.year + 1900; m = tm.mon + 1; d = tm.mday;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
255 h = tm.hour; mi = tm.min; s = tm.sec + tm.usec / 1e6;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
256 if (rY < ry)
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
257 if (y > 1999)
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
258 y -= 2000;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
259 else
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
260 y -= 1900;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
261 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
262 y += p - mod (p, 100);
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
263 if (y < p)
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
264 y += 100;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
265 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
266 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
267 if (! fy && ! fm && ! fd)
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8411
diff changeset
268 tmp = localtime (time ());
14743
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
269 ## default is January 1st of current year
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8411
diff changeset
270 y = tmp.year + 1900;
14743
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
271 m = 1;
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
272 d = 1;
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
273 elseif (! fy && fm && fd)
8506
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8411
diff changeset
274 tmp = localtime (time ());
bc982528de11 comment style fixes
John W. Eaton <jwe@octave.org>
parents: 8411
diff changeset
275 y = tmp.year + 1900;
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
276 elseif (fy && fm && ! fd)
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
277 d = 1;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
278 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
279 if (! fh && ! fmi && ! fs)
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
280 h = mi = s = 0;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
281 elseif (fh && fmi && ! fs)
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
282 s = 0;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
283 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
284 else
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
285 y = m = d = h = mi = s = 0;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
286 found = false;
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
287 endif
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
288
11086
af03ff97df7b datevec.m: use endfunction to mark end of primary function and subfunctions
John W. Eaton <jwe@octave.org>
parents: 10793
diff changeset
289 endfunction
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
290
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
291
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
292 %!demo
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
293 %! ## Current date and time
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
294 %! datevec (now ())
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
295
14743
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
296 %!shared yr
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
297 %! yr = datevec (now)(1); # Some tests could fail around midnight!
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
298 ## tests for standard formats: 0, 1, 2, 6, 13, 14, 15, 16, 23
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
299 %!assert (datevec ("07-Sep-2000 15:38:09"), [2000,9,7,15,38,9])
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
300 %!assert (datevec ("07-Sep-2000"), [2000,9,7,0,0,0])
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
301 %!assert (datevec ("09/07/00"), [2000,9,7,0,0,0])
14743
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
302 %!assert (datevec ("09/13"), [yr,9,13,0,0,0])
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
303 %!assert (datevec ("15:38:09"), [yr,1,1,15,38,9])
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
304 %!assert (datevec ("3:38:09 PM"), [yr,1,1,15,38,9])
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
305 %!assert (datevec ("15:38"), [yr,1,1,15,38,0])
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
306 %!assert (datevec ("03:38 PM"), [yr,1,1,15,38,0])
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
307 %!assert (datevec ("03/13/1962"), [1962,3,13,0,0,0])
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
308
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
309 %% Test millisecond format FFF
14743
b7675598094a datevec.m: Support more date string input formats for Matlab compatibility (bug #36563)
Rik <octave@nomad.inbox5.com>
parents: 14363
diff changeset
310 %!assert (datevec ("15:38:21.25", "HH:MM:SS.FFF"), [yr,1,1,15,38,21.025])
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
311
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
312 # Other tests
14363
f3d52523cde1 Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
313 %!assert (datenum (datevec ([-1e4:1e4])), [-1e4:1e4]');
5687
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
314 %!test
a2902024bc4e [project @ 2006-03-16 20:22:40 by jwe]
jwe
parents:
diff changeset
315 %! t = linspace (-2e5, 2e5, 10993);
5860
b645066d40ad [project @ 2006-06-16 05:01:38 by jwe]
jwe
parents: 5859
diff changeset
316 %! assert (all (abs (datenum (datevec (t)) - t') < 1e-5));
19418
7d272300a880 datevec.m: Fix negative number outputs with integer (non-float) inputs (bug #43753).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 17744
diff changeset
317 %!assert (double (datevec (int64 (datenum ([2014 6 1])))), datevec (datenum ([2014 6 1])))
7d272300a880 datevec.m: Fix negative number outputs with integer (non-float) inputs (bug #43753).
Nir Krakauer <nkrakauer@ccny.cuny.edu>
parents: 17744
diff changeset
318 %!assert (double (datevec (int64 (datenum ([2014 6 18])))), datevec (datenum ([2014 6 18])))
13848
40e32fe44aaa Ugrade time functions to accept millisecond format string FFF (Bug #34586)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
319