History log of /netbsd-current/bin/date/date.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.66 21-Jan-2024 christos

Handle -d %Y%m%d in the tools version. This is used in the release notes
Makefile.inc when BUILDID is specified. Consider providing parsedate(3)
in libcompat, but then we'd need yacc...


# 1.65 31-May-2023 kim

Add -R to usage


# 1.64 31-May-2023 kim

Add -R option for displaying time in RFC 5322 format, similar to GNU date.


Revision tags: netbsd-10-base
# 1.63 22-Oct-2022 christos

branches: 1.63.2;
Add -f option to set the time. From FreeBSD.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.62 26-May-2021 christos

tool changes


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.61 01-Sep-2014 dholland

branches: 1.61.16; 1.61.18; 1.61.22;
Provide real error messages.
Inspired by PR 49169 from David H. Gutteridge, but a much broader patch :-)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.60 27-Aug-2011 joerg

Annotate dead functions


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
# 1.59 29-Jan-2011 christos

revert the revert and fix the code properly.


# 1.58 28-Jan-2011 drochner

roll back to 20101210 -- the current version just hung if one tried
to set the date


Revision tags: matt-mips64-premerge-20101231
# 1.57 12-Dec-2010 christos

branches: 1.57.2;
check return value of localtime.


# 1.56 11-Dec-2010 christos

- check return of strtoll
- misc cleanup


# 1.55 03-Oct-2010 gson

Simplify by using setenv() instead of putenv().


# 1.54 02-Oct-2010 gson

putenv() no longer accepts a const string


# 1.53 29-May-2010 dholland

Don't blow up on date +''. Patch from Robert Elz in followup to PR 39392.


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.52 20-Jul-2008 lukem

branches: 1.52.4;
Remove the \n and tabs from the __COPYRIGHT() strings.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.51 24-Feb-2008 dholland

branches: 1.51.4;
Use strtoll rather than strtol to read the -r argument, so it will work
for wider time_t. Also mark a timed-related y2038 lossage for whenever
someone figures out the best way to shoot timed.


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base
# 1.50 04-Feb-2007 cbiere

branches: 1.50.4; 1.50.8;
Use size_t not int for strlen().


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.49 20-Nov-2006 christos

branches: 1.49.2;
getdate -> parsedate


# 1.48 17-Nov-2006 christos

getdate is in libutil.


# 1.47 15-Nov-2006 christos

Add -d option, similar to gnu date.


# 1.46 15-Nov-2006 jdarrow

Add -j flag to not actually change the clock, just parse the date given
(if any) and then display it in the format given. Matches similar -j
flag functionality in FreeBSD/OpenBSD.

Change requested by George Georgalis on netbsd-users.

While I'm here, disambiguate the letters in the date string, by using
the same option letters as used by strftime(3).


# 1.45 07-Oct-2006 elad

PR/28450: David H. Gutteridge: date(1) does not validate its input and
accepts and processes impossible dates

Patch applied, thanks!


# 1.44 17-Aug-2006 jnemeth

don't include program name when calling err()


Revision tags: abandoned-netbsd-4-base
# 1.43 23-Jul-2006 christos

PR/34055: Kevin Massey: Date uses a fixed 1K buffer for strftime
but does not check when strftime fails because the buffer is too small.
Our implementation of strftime does not NUL terminat the buffer
on failure (it does not have to; the results are undefined), so
garbage gets printed. Use a dynamically allocated buffer instead.


# 1.42 22-Jul-2005 peter

More minor cleanup:
- remove unnecessary prototype for main()
- use symbolic exit code
- KNF & wrap a long line


# 1.41 22-Jul-2005 hubertf

Minor code cleanup:

* remove unneeded cast
* use err() instead of perror() + exit()
* use symbolic exit code

Patch contributed by Liam J. Foy <liamfoy@sepulcrum.org> in private mail.


# 1.40 26-Jun-2005 christos

sprinkle a little const, and now everything compiles with WARNS=3


# 1.39 15-May-2005 dsl

Set (and report) the new time (not the old one).
I broke it in rev 1.38, someone has finally noticed....


# 1.38 18-Apr-2005 dsl

Add a '-a' option to set the time using adjtime(2) instead of settimeofday(2).
Fix usage so that the options which apply to dat/time setting are on the
correct line.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.37 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.


# 1.36 04-Aug-2003 jschauma

As discusses a little while back on tech-userlevel:

If stdout is a tty, use vis(3) to print any filenames to prevent garbage
from being printed if the filename contains control- or other non-printable
characters.

While here, sprinkle some EXIT_FAILURE and NOTREACHED where appropriate.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.35 16-Sep-2001 wiz

Use setprogname. Patch by Petri Koistinen.


# 1.34 13-Sep-2001 wiz

ANSIfication and KNF fixes by Petri Koistinen in bin/13691.


# 1.33 08-Jul-2001 gmcgarry

setthetime() is prototyped static; make it so.


# 1.32 23-Oct-2000 simonb

Use strtol() to convert the -r parameter so we can use alternate bases
for that input.


# 1.31 08-Oct-2000 bjh21

When setting the date, ask mktime() to work out whether we're in DST or not.
Seems to fix PR bin/8750.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.30 14-Apr-2000 simonb

branches: 1.30.4;
Don't declare 'extern opt*' getopt variables.


# 1.29 04-Jan-2000 kleink

Make this slightly more portable by using putenv().


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 04-Nov-1998 christos

cast to unsigned char for is*()


# 1.27 24-Oct-1998 mycroft

GMT -> UTC


# 1.26 14-Oct-1998 wsanchez

For the case where mktime() fails exit with "illegal time" error rather than
"illegal time format", which is misleading.


# 1.25 28-Jul-1998 mycroft

Be more retentive about use of NOTREACHED and noreturn.


# 1.24 28-Jul-1998 mycroft

Delint.


# 1.23 27-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.22 01-Apr-1998 kleink

Need <time.h> for time(), strftime(), localtime() and mktime() prototypes.


# 1.21 21-Jan-1998 mycroft

Slight code rearrangement.


# 1.20 20-Jan-1998 mycroft

Don't validate the mmddhhmm.ss values here. mktime(3) does it.


# 1.19 20-Jan-1998 mycroft

Make the documented parsing order for the date match reality.


# 1.18 20-Jan-1998 mycroft

Allow a century to be specified.
Cut and paste some text from touch(1) about date parsing.


# 1.17 20-Jan-1998 mycroft

Use TM_YEAR_BASE to adjust tm_year, not 1900.


# 1.16 05-Nov-1997 cgd

lint


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.15 20-Jul-1997 thorpej

branches: 1.15.2;
__RCSID()/__COPYRIGHT()/prototype police.


# 1.14 26-Mar-1997 cgd

pull in util.h rather than prototypeing logtwmp() locally.


# 1.13 24-Jan-1997 perry

remove obsolete -d and -t options -- kernel timezone handling is long gone


# 1.12 09-Jan-1997 tls

kill use of register


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.11 07-Sep-1995 jtc

Sync with 4.4lite2


# 1.10 23-Apr-1995 cgd

clean up RCS Ids slightly, etc.


# 1.9 21-Mar-1995 cgd

convert to new RCS id conventions.


# 1.8 22-Sep-1994 mycroft

Merge 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 31-Dec-1993 jtc

Minor tweaks.


# 1.6 16-Aug-1993 jtc

1003.2: 4.15.4: The output always shall be terminated by a newline character.


# 1.5 01-Aug-1993 mycroft

Add RCS identifiers.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 21-Jun-1993 deraadt

date comamnd ignored seconds value. patch from <mhw@cs.brown.edu>


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.65 31-May-2023 kim

Add -R to usage


# 1.64 31-May-2023 kim

Add -R option for displaying time in RFC 5322 format, similar to GNU date.


Revision tags: netbsd-10-base
# 1.63 22-Oct-2022 christos

branches: 1.63.2;
Add -f option to set the time. From FreeBSD.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.62 26-May-2021 christos

tool changes


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.61 01-Sep-2014 dholland

branches: 1.61.16; 1.61.18; 1.61.22;
Provide real error messages.
Inspired by PR 49169 from David H. Gutteridge, but a much broader patch :-)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.60 27-Aug-2011 joerg

Annotate dead functions


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
# 1.59 29-Jan-2011 christos

revert the revert and fix the code properly.


# 1.58 28-Jan-2011 drochner

roll back to 20101210 -- the current version just hung if one tried
to set the date


Revision tags: matt-mips64-premerge-20101231
# 1.57 12-Dec-2010 christos

branches: 1.57.2;
check return value of localtime.


# 1.56 11-Dec-2010 christos

- check return of strtoll
- misc cleanup


# 1.55 03-Oct-2010 gson

Simplify by using setenv() instead of putenv().


# 1.54 02-Oct-2010 gson

putenv() no longer accepts a const string


# 1.53 29-May-2010 dholland

Don't blow up on date +''. Patch from Robert Elz in followup to PR 39392.


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.52 20-Jul-2008 lukem

branches: 1.52.4;
Remove the \n and tabs from the __COPYRIGHT() strings.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.51 24-Feb-2008 dholland

branches: 1.51.4;
Use strtoll rather than strtol to read the -r argument, so it will work
for wider time_t. Also mark a timed-related y2038 lossage for whenever
someone figures out the best way to shoot timed.


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base
# 1.50 04-Feb-2007 cbiere

branches: 1.50.4; 1.50.8;
Use size_t not int for strlen().


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.49 20-Nov-2006 christos

branches: 1.49.2;
getdate -> parsedate


# 1.48 17-Nov-2006 christos

getdate is in libutil.


# 1.47 15-Nov-2006 christos

Add -d option, similar to gnu date.


# 1.46 15-Nov-2006 jdarrow

Add -j flag to not actually change the clock, just parse the date given
(if any) and then display it in the format given. Matches similar -j
flag functionality in FreeBSD/OpenBSD.

Change requested by George Georgalis on netbsd-users.

While I'm here, disambiguate the letters in the date string, by using
the same option letters as used by strftime(3).


# 1.45 07-Oct-2006 elad

PR/28450: David H. Gutteridge: date(1) does not validate its input and
accepts and processes impossible dates

Patch applied, thanks!


# 1.44 17-Aug-2006 jnemeth

don't include program name when calling err()


Revision tags: abandoned-netbsd-4-base
# 1.43 23-Jul-2006 christos

PR/34055: Kevin Massey: Date uses a fixed 1K buffer for strftime
but does not check when strftime fails because the buffer is too small.
Our implementation of strftime does not NUL terminat the buffer
on failure (it does not have to; the results are undefined), so
garbage gets printed. Use a dynamically allocated buffer instead.


# 1.42 22-Jul-2005 peter

More minor cleanup:
- remove unnecessary prototype for main()
- use symbolic exit code
- KNF & wrap a long line


# 1.41 22-Jul-2005 hubertf

Minor code cleanup:

* remove unneeded cast
* use err() instead of perror() + exit()
* use symbolic exit code

Patch contributed by Liam J. Foy <liamfoy@sepulcrum.org> in private mail.


# 1.40 26-Jun-2005 christos

sprinkle a little const, and now everything compiles with WARNS=3


# 1.39 15-May-2005 dsl

Set (and report) the new time (not the old one).
I broke it in rev 1.38, someone has finally noticed....


# 1.38 18-Apr-2005 dsl

Add a '-a' option to set the time using adjtime(2) instead of settimeofday(2).
Fix usage so that the options which apply to dat/time setting are on the
correct line.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.37 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.


# 1.36 04-Aug-2003 jschauma

As discusses a little while back on tech-userlevel:

If stdout is a tty, use vis(3) to print any filenames to prevent garbage
from being printed if the filename contains control- or other non-printable
characters.

While here, sprinkle some EXIT_FAILURE and NOTREACHED where appropriate.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.35 16-Sep-2001 wiz

Use setprogname. Patch by Petri Koistinen.


# 1.34 13-Sep-2001 wiz

ANSIfication and KNF fixes by Petri Koistinen in bin/13691.


# 1.33 08-Jul-2001 gmcgarry

setthetime() is prototyped static; make it so.


# 1.32 23-Oct-2000 simonb

Use strtol() to convert the -r parameter so we can use alternate bases
for that input.


# 1.31 08-Oct-2000 bjh21

When setting the date, ask mktime() to work out whether we're in DST or not.
Seems to fix PR bin/8750.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.30 14-Apr-2000 simonb

branches: 1.30.4;
Don't declare 'extern opt*' getopt variables.


# 1.29 04-Jan-2000 kleink

Make this slightly more portable by using putenv().


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 04-Nov-1998 christos

cast to unsigned char for is*()


# 1.27 24-Oct-1998 mycroft

GMT -> UTC


# 1.26 14-Oct-1998 wsanchez

For the case where mktime() fails exit with "illegal time" error rather than
"illegal time format", which is misleading.


# 1.25 28-Jul-1998 mycroft

Be more retentive about use of NOTREACHED and noreturn.


# 1.24 28-Jul-1998 mycroft

Delint.


# 1.23 27-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.22 01-Apr-1998 kleink

Need <time.h> for time(), strftime(), localtime() and mktime() prototypes.


# 1.21 21-Jan-1998 mycroft

Slight code rearrangement.


# 1.20 20-Jan-1998 mycroft

Don't validate the mmddhhmm.ss values here. mktime(3) does it.


# 1.19 20-Jan-1998 mycroft

Make the documented parsing order for the date match reality.


# 1.18 20-Jan-1998 mycroft

Allow a century to be specified.
Cut and paste some text from touch(1) about date parsing.


# 1.17 20-Jan-1998 mycroft

Use TM_YEAR_BASE to adjust tm_year, not 1900.


# 1.16 05-Nov-1997 cgd

lint


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.15 20-Jul-1997 thorpej

branches: 1.15.2;
__RCSID()/__COPYRIGHT()/prototype police.


# 1.14 26-Mar-1997 cgd

pull in util.h rather than prototypeing logtwmp() locally.


# 1.13 24-Jan-1997 perry

remove obsolete -d and -t options -- kernel timezone handling is long gone


# 1.12 09-Jan-1997 tls

kill use of register


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.11 07-Sep-1995 jtc

Sync with 4.4lite2


# 1.10 23-Apr-1995 cgd

clean up RCS Ids slightly, etc.


# 1.9 21-Mar-1995 cgd

convert to new RCS id conventions.


# 1.8 22-Sep-1994 mycroft

Merge 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 31-Dec-1993 jtc

Minor tweaks.


# 1.6 16-Aug-1993 jtc

1003.2: 4.15.4: The output always shall be terminated by a newline character.


# 1.5 01-Aug-1993 mycroft

Add RCS identifiers.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 21-Jun-1993 deraadt

date comamnd ignored seconds value. patch from <mhw@cs.brown.edu>


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.63 22-Oct-2022 christos

Add -f option to set the time. From FreeBSD.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1
# 1.62 26-May-2021 christos

tool changes


Revision tags: netbsd-9-3-RELEASE netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.61 01-Sep-2014 dholland

branches: 1.61.16; 1.61.22;
Provide real error messages.
Inspired by PR 49169 from David H. Gutteridge, but a much broader patch :-)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.60 27-Aug-2011 joerg

Annotate dead functions


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
# 1.59 29-Jan-2011 christos

revert the revert and fix the code properly.


# 1.58 28-Jan-2011 drochner

roll back to 20101210 -- the current version just hung if one tried
to set the date


Revision tags: matt-mips64-premerge-20101231
# 1.57 12-Dec-2010 christos

branches: 1.57.2;
check return value of localtime.


# 1.56 11-Dec-2010 christos

- check return of strtoll
- misc cleanup


# 1.55 03-Oct-2010 gson

Simplify by using setenv() instead of putenv().


# 1.54 02-Oct-2010 gson

putenv() no longer accepts a const string


# 1.53 29-May-2010 dholland

Don't blow up on date +''. Patch from Robert Elz in followup to PR 39392.


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.52 20-Jul-2008 lukem

branches: 1.52.4;
Remove the \n and tabs from the __COPYRIGHT() strings.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.51 24-Feb-2008 dholland

branches: 1.51.4;
Use strtoll rather than strtol to read the -r argument, so it will work
for wider time_t. Also mark a timed-related y2038 lossage for whenever
someone figures out the best way to shoot timed.


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base
# 1.50 04-Feb-2007 cbiere

branches: 1.50.4; 1.50.8;
Use size_t not int for strlen().


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.49 20-Nov-2006 christos

branches: 1.49.2;
getdate -> parsedate


# 1.48 17-Nov-2006 christos

getdate is in libutil.


# 1.47 15-Nov-2006 christos

Add -d option, similar to gnu date.


# 1.46 15-Nov-2006 jdarrow

Add -j flag to not actually change the clock, just parse the date given
(if any) and then display it in the format given. Matches similar -j
flag functionality in FreeBSD/OpenBSD.

Change requested by George Georgalis on netbsd-users.

While I'm here, disambiguate the letters in the date string, by using
the same option letters as used by strftime(3).


# 1.45 07-Oct-2006 elad

PR/28450: David H. Gutteridge: date(1) does not validate its input and
accepts and processes impossible dates

Patch applied, thanks!


# 1.44 17-Aug-2006 jnemeth

don't include program name when calling err()


Revision tags: abandoned-netbsd-4-base
# 1.43 23-Jul-2006 christos

PR/34055: Kevin Massey: Date uses a fixed 1K buffer for strftime
but does not check when strftime fails because the buffer is too small.
Our implementation of strftime does not NUL terminat the buffer
on failure (it does not have to; the results are undefined), so
garbage gets printed. Use a dynamically allocated buffer instead.


# 1.42 22-Jul-2005 peter

More minor cleanup:
- remove unnecessary prototype for main()
- use symbolic exit code
- KNF & wrap a long line


# 1.41 22-Jul-2005 hubertf

Minor code cleanup:

* remove unneeded cast
* use err() instead of perror() + exit()
* use symbolic exit code

Patch contributed by Liam J. Foy <liamfoy@sepulcrum.org> in private mail.


# 1.40 26-Jun-2005 christos

sprinkle a little const, and now everything compiles with WARNS=3


# 1.39 15-May-2005 dsl

Set (and report) the new time (not the old one).
I broke it in rev 1.38, someone has finally noticed....


# 1.38 18-Apr-2005 dsl

Add a '-a' option to set the time using adjtime(2) instead of settimeofday(2).
Fix usage so that the options which apply to dat/time setting are on the
correct line.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.37 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.


# 1.36 04-Aug-2003 jschauma

As discusses a little while back on tech-userlevel:

If stdout is a tty, use vis(3) to print any filenames to prevent garbage
from being printed if the filename contains control- or other non-printable
characters.

While here, sprinkle some EXIT_FAILURE and NOTREACHED where appropriate.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.35 16-Sep-2001 wiz

Use setprogname. Patch by Petri Koistinen.


# 1.34 13-Sep-2001 wiz

ANSIfication and KNF fixes by Petri Koistinen in bin/13691.


# 1.33 08-Jul-2001 gmcgarry

setthetime() is prototyped static; make it so.


# 1.32 23-Oct-2000 simonb

Use strtol() to convert the -r parameter so we can use alternate bases
for that input.


# 1.31 08-Oct-2000 bjh21

When setting the date, ask mktime() to work out whether we're in DST or not.
Seems to fix PR bin/8750.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.30 14-Apr-2000 simonb

branches: 1.30.4;
Don't declare 'extern opt*' getopt variables.


# 1.29 04-Jan-2000 kleink

Make this slightly more portable by using putenv().


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 04-Nov-1998 christos

cast to unsigned char for is*()


# 1.27 24-Oct-1998 mycroft

GMT -> UTC


# 1.26 14-Oct-1998 wsanchez

For the case where mktime() fails exit with "illegal time" error rather than
"illegal time format", which is misleading.


# 1.25 28-Jul-1998 mycroft

Be more retentive about use of NOTREACHED and noreturn.


# 1.24 28-Jul-1998 mycroft

Delint.


# 1.23 27-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.22 01-Apr-1998 kleink

Need <time.h> for time(), strftime(), localtime() and mktime() prototypes.


# 1.21 21-Jan-1998 mycroft

Slight code rearrangement.


# 1.20 20-Jan-1998 mycroft

Don't validate the mmddhhmm.ss values here. mktime(3) does it.


# 1.19 20-Jan-1998 mycroft

Make the documented parsing order for the date match reality.


# 1.18 20-Jan-1998 mycroft

Allow a century to be specified.
Cut and paste some text from touch(1) about date parsing.


# 1.17 20-Jan-1998 mycroft

Use TM_YEAR_BASE to adjust tm_year, not 1900.


# 1.16 05-Nov-1997 cgd

lint


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.15 20-Jul-1997 thorpej

branches: 1.15.2;
__RCSID()/__COPYRIGHT()/prototype police.


# 1.14 26-Mar-1997 cgd

pull in util.h rather than prototypeing logtwmp() locally.


# 1.13 24-Jan-1997 perry

remove obsolete -d and -t options -- kernel timezone handling is long gone


# 1.12 09-Jan-1997 tls

kill use of register


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.11 07-Sep-1995 jtc

Sync with 4.4lite2


# 1.10 23-Apr-1995 cgd

clean up RCS Ids slightly, etc.


# 1.9 21-Mar-1995 cgd

convert to new RCS id conventions.


# 1.8 22-Sep-1994 mycroft

Merge 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 31-Dec-1993 jtc

Minor tweaks.


# 1.6 16-Aug-1993 jtc

1003.2: 4.15.4: The output always shall be terminated by a newline character.


# 1.5 01-Aug-1993 mycroft

Add RCS identifiers.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 21-Jun-1993 deraadt

date comamnd ignored seconds value. patch from <mhw@cs.brown.edu>


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.62 26-May-2021 christos

tool changes


Revision tags: netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.61 01-Sep-2014 dholland

branches: 1.61.16;
Provide real error messages.
Inspired by PR 49169 from David H. Gutteridge, but a much broader patch :-)


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-7-base yamt-pagecache-base9 yamt-pagecache-tag8 netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE tls-earlyentropy-base riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3 netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 agc-symver-base netbsd-6-1-RC2 netbsd-6-1-RC1 yamt-pagecache-base8 netbsd-6-0-1-RELEASE yamt-pagecache-base7 matt-nb6-plus-nbase yamt-pagecache-base6 netbsd-6-0-RELEASE netbsd-6-0-RC2 tls-maxphys-base matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.60 27-Aug-2011 joerg

Annotate dead functions


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
# 1.59 29-Jan-2011 christos

revert the revert and fix the code properly.


# 1.58 28-Jan-2011 drochner

roll back to 20101210 -- the current version just hung if one tried
to set the date


Revision tags: matt-mips64-premerge-20101231
# 1.57 12-Dec-2010 christos

branches: 1.57.2;
check return value of localtime.


# 1.56 11-Dec-2010 christos

- check return of strtoll
- misc cleanup


# 1.55 03-Oct-2010 gson

Simplify by using setenv() instead of putenv().


# 1.54 02-Oct-2010 gson

putenv() no longer accepts a const string


# 1.53 29-May-2010 dholland

Don't blow up on date +''. Patch from Robert Elz in followup to PR 39392.


Revision tags: netbsd-5-1-5-RELEASE netbsd-5-1-4-RELEASE netbsd-5-1-3-RELEASE netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2
# 1.52 20-Jul-2008 lukem

branches: 1.52.4;
Remove the \n and tabs from the __COPYRIGHT() strings.


Revision tags: wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase hpcarm-cleanup-base
# 1.51 24-Feb-2008 dholland

branches: 1.51.4;
Use strtoll rather than strtol to read the -r argument, so it will work
for wider time_t. Also mark a timed-related y2038 lossage for whenever
someone figures out the best way to shoot timed.


Revision tags: matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base
# 1.50 04-Feb-2007 cbiere

branches: 1.50.4; 1.50.8;
Use size_t not int for strlen().


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.49 20-Nov-2006 christos

branches: 1.49.2;
getdate -> parsedate


# 1.48 17-Nov-2006 christos

getdate is in libutil.


# 1.47 15-Nov-2006 christos

Add -d option, similar to gnu date.


# 1.46 15-Nov-2006 jdarrow

Add -j flag to not actually change the clock, just parse the date given
(if any) and then display it in the format given. Matches similar -j
flag functionality in FreeBSD/OpenBSD.

Change requested by George Georgalis on netbsd-users.

While I'm here, disambiguate the letters in the date string, by using
the same option letters as used by strftime(3).


# 1.45 07-Oct-2006 elad

PR/28450: David H. Gutteridge: date(1) does not validate its input and
accepts and processes impossible dates

Patch applied, thanks!


# 1.44 17-Aug-2006 jnemeth

don't include program name when calling err()


Revision tags: abandoned-netbsd-4-base
# 1.43 23-Jul-2006 christos

PR/34055: Kevin Massey: Date uses a fixed 1K buffer for strftime
but does not check when strftime fails because the buffer is too small.
Our implementation of strftime does not NUL terminat the buffer
on failure (it does not have to; the results are undefined), so
garbage gets printed. Use a dynamically allocated buffer instead.


# 1.42 22-Jul-2005 peter

More minor cleanup:
- remove unnecessary prototype for main()
- use symbolic exit code
- KNF & wrap a long line


# 1.41 22-Jul-2005 hubertf

Minor code cleanup:

* remove unneeded cast
* use err() instead of perror() + exit()
* use symbolic exit code

Patch contributed by Liam J. Foy <liamfoy@sepulcrum.org> in private mail.


# 1.40 26-Jun-2005 christos

sprinkle a little const, and now everything compiles with WARNS=3


# 1.39 15-May-2005 dsl

Set (and report) the new time (not the old one).
I broke it in rev 1.38, someone has finally noticed....


# 1.38 18-Apr-2005 dsl

Add a '-a' option to set the time using adjtime(2) instead of settimeofday(2).
Fix usage so that the options which apply to dat/time setting are on the
correct line.


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-2-0-3-RELEASE netbsd-2-1-RELEASE netbsd-2-1-RC6 netbsd-2-1-RC5 netbsd-2-1-RC4 netbsd-2-1-RC3 netbsd-2-1-RC2 netbsd-2-1-RC1 netbsd-2-0-2-RELEASE netbsd-3-base netbsd-2-0-1-RELEASE netbsd-2-base netbsd-2-0-RELEASE netbsd-2-0-RC5 netbsd-2-0-RC4 netbsd-2-0-RC3 netbsd-2-0-RC2 netbsd-2-0-RC1 netbsd-2-0-base
# 1.37 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.


# 1.36 04-Aug-2003 jschauma

As discusses a little while back on tech-userlevel:

If stdout is a tty, use vis(3) to print any filenames to prevent garbage
from being printed if the filename contains control- or other non-printable
characters.

While here, sprinkle some EXIT_FAILURE and NOTREACHED where appropriate.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 fvdl_fs64_base netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.35 16-Sep-2001 wiz

Use setprogname. Patch by Petri Koistinen.


# 1.34 13-Sep-2001 wiz

ANSIfication and KNF fixes by Petri Koistinen in bin/13691.


# 1.33 08-Jul-2001 gmcgarry

setthetime() is prototyped static; make it so.


# 1.32 23-Oct-2000 simonb

Use strtol() to convert the -r parameter so we can use alternate bases
for that input.


# 1.31 08-Oct-2000 bjh21

When setting the date, ask mktime() to work out whether we're in DST or not.
Seems to fix PR bin/8750.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base
# 1.30 14-Apr-2000 simonb

branches: 1.30.4;
Don't declare 'extern opt*' getopt variables.


# 1.29 04-Jan-2000 kleink

Make this slightly more portable by using putenv().


Revision tags: netbsd-1-4-PATCH003 netbsd-1-4-PATCH002 wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.28 04-Nov-1998 christos

cast to unsigned char for is*()


# 1.27 24-Oct-1998 mycroft

GMT -> UTC


# 1.26 14-Oct-1998 wsanchez

For the case where mktime() fails exit with "illegal time" error rather than
"illegal time format", which is misleading.


# 1.25 28-Jul-1998 mycroft

Be more retentive about use of NOTREACHED and noreturn.


# 1.24 28-Jul-1998 mycroft

Delint.


# 1.23 27-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.22 01-Apr-1998 kleink

Need <time.h> for time(), strftime(), localtime() and mktime() prototypes.


# 1.21 21-Jan-1998 mycroft

Slight code rearrangement.


# 1.20 20-Jan-1998 mycroft

Don't validate the mmddhhmm.ss values here. mktime(3) does it.


# 1.19 20-Jan-1998 mycroft

Make the documented parsing order for the date match reality.


# 1.18 20-Jan-1998 mycroft

Allow a century to be specified.
Cut and paste some text from touch(1) about date parsing.


# 1.17 20-Jan-1998 mycroft

Use TM_YEAR_BASE to adjust tm_year, not 1900.


# 1.16 05-Nov-1997 cgd

lint


Revision tags: netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.15 20-Jul-1997 thorpej

branches: 1.15.2;
__RCSID()/__COPYRIGHT()/prototype police.


# 1.14 26-Mar-1997 cgd

pull in util.h rather than prototypeing logtwmp() locally.


# 1.13 24-Jan-1997 perry

remove obsolete -d and -t options -- kernel timezone handling is long gone


# 1.12 09-Jan-1997 tls

kill use of register


Revision tags: netbsd-1-2-PATCH001 netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.11 07-Sep-1995 jtc

Sync with 4.4lite2


# 1.10 23-Apr-1995 cgd

clean up RCS Ids slightly, etc.


# 1.9 21-Mar-1995 cgd

convert to new RCS id conventions.


# 1.8 22-Sep-1994 mycroft

Merge 4.4-Lite version.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 31-Dec-1993 jtc

Minor tweaks.


# 1.6 16-Aug-1993 jtc

1003.2: 4.15.4: The output always shall be terminated by a newline character.


# 1.5 01-Aug-1993 mycroft

Add RCS identifiers.


Revision tags: netbsd-0-9-RELEASE netbsd-0-9-BETA netbsd-0-9-ALPHA2 netbsd-0-9-ALPHA netbsd-0-9-base
# 1.4 21-Jun-1993 deraadt

date comamnd ignored seconds value. patch from <mhw@cs.brown.edu>


Revision tags: netbsd-0-8 netbsd-alpha-1
# 1.3 23-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.61 01-Sep-2014 dholland

Provide real error messages.
Inspired by PR 49169 from David H. Gutteridge, but a much broader patch :-)


# 1.60 27-Aug-2011 joerg

Annotate dead functions


# 1.59 28-Jan-2011 christos

revert the revert and fix the code properly.


# 1.58 28-Jan-2011 drochner

roll back to 20101210 -- the current version just hung if one tried
to set the date


# 1.57 11-Dec-2010 christos

branches: 1.57.2;
check return value of localtime.


# 1.56 11-Dec-2010 christos

- check return of strtoll
- misc cleanup


# 1.55 03-Oct-2010 gson

Simplify by using setenv() instead of putenv().


# 1.54 02-Oct-2010 gson

putenv() no longer accepts a const string


# 1.53 29-May-2010 dholland

Don't blow up on date +''. Patch from Robert Elz in followup to PR 39392.


# 1.52 19-Jul-2008 lukem

branches: 1.52.4;
Remove the \n and tabs from the __COPYRIGHT() strings.


# 1.51 23-Feb-2008 dholland

branches: 1.51.4;
Use strtoll rather than strtol to read the -r argument, so it will work
for wider time_t. Also mark a timed-related y2038 lossage for whenever
someone figures out the best way to shoot timed.


# 1.50 04-Feb-2007 cbiere

branches: 1.50.4; 1.50.8;
Use size_t not int for strlen().


# 1.49 20-Nov-2006 christos

branches: 1.49.2;
getdate -> parsedate


# 1.48 17-Nov-2006 christos

getdate is in libutil.


# 1.47 15-Nov-2006 christos

Add -d option, similar to gnu date.


# 1.46 14-Nov-2006 jdarrow

Add -j flag to not actually change the clock, just parse the date given
(if any) and then display it in the format given. Matches similar -j
flag functionality in FreeBSD/OpenBSD.

Change requested by George Georgalis on netbsd-users.

While I'm here, disambiguate the letters in the date string, by using
the same option letters as used by strftime(3).


# 1.45 07-Oct-2006 elad

PR/28450: David H. Gutteridge: date(1) does not validate its input and
accepts and processes impossible dates

Patch applied, thanks!


# 1.44 17-Aug-2006 jnemeth

don't include program name when calling err()


# 1.43 23-Jul-2006 christos

PR/34055: Kevin Massey: Date uses a fixed 1K buffer for strftime
but does not check when strftime fails because the buffer is too small.
Our implementation of strftime does not NUL terminat the buffer
on failure (it does not have to; the results are undefined), so
garbage gets printed. Use a dynamically allocated buffer instead.


# 1.42 22-Jul-2005 peter

More minor cleanup:
- remove unnecessary prototype for main()
- use symbolic exit code
- KNF & wrap a long line


# 1.41 22-Jul-2005 hubertf

Minor code cleanup:

* remove unneeded cast
* use err() instead of perror() + exit()
* use symbolic exit code

Patch contributed by Liam J. Foy <liamfoy@sepulcrum.org> in private mail.


# 1.40 26-Jun-2005 christos

sprinkle a little const, and now everything compiles with WARNS=3


# 1.39 15-May-2005 dsl

Set (and report) the new time (not the old one).
I broke it in rev 1.38, someone has finally noticed....


# 1.38 18-Apr-2005 dsl

Add a '-a' option to set the time using adjtime(2) instead of settimeofday(2).
Fix usage so that the options which apply to dat/time setting are on the
correct line.


# 1.37 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22249, verified by myself.


# 1.36 04-Aug-2003 jschauma

As discusses a little while back on tech-userlevel:

If stdout is a tty, use vis(3) to print any filenames to prevent garbage
from being printed if the filename contains control- or other non-printable
characters.

While here, sprinkle some EXIT_FAILURE and NOTREACHED where appropriate.


# 1.35 16-Sep-2001 wiz

Use setprogname. Patch by Petri Koistinen.


# 1.34 13-Sep-2001 wiz

ANSIfication and KNF fixes by Petri Koistinen in bin/13691.


# 1.33 07-Jul-2001 gmcgarry

setthetime() is prototyped static; make it so.


# 1.32 22-Oct-2000 simonb

Use strtol() to convert the -r parameter so we can use alternate bases
for that input.


# 1.31 08-Oct-2000 bjh21

When setting the date, ask mktime() to work out whether we're in DST or not.
Seems to fix PR bin/8750.


# 1.30 13-Apr-2000 simonb

branches: 1.30.4;
Don't declare 'extern opt*' getopt variables.


# 1.29 04-Jan-2000 kleink

Make this slightly more portable by using putenv().


# 1.28 04-Nov-1998 christos

cast to unsigned char for is*()


# 1.27 23-Oct-1998 mycroft

GMT -> UTC


# 1.26 13-Oct-1998 wsanchez

For the case where mktime() fails exit with "illegal time" error rather than
"illegal time format", which is misleading.


# 1.25 28-Jul-1998 mycroft

Be more retentive about use of NOTREACHED and noreturn.


# 1.24 27-Jul-1998 mycroft

Delint.


# 1.23 26-Jul-1998 mycroft

__AUDIT__ cleanup.


# 1.22 01-Apr-1998 kleink

Need <time.h> for time(), strftime(), localtime() and mktime() prototypes.


# 1.21 20-Jan-1998 mycroft

Slight code rearrangement.


# 1.20 20-Jan-1998 mycroft

Don't validate the mmddhhmm.ss values here. mktime(3) does it.


# 1.19 20-Jan-1998 mycroft

Make the documented parsing order for the date match reality.


# 1.18 20-Jan-1998 mycroft

Allow a century to be specified.
Cut and paste some text from touch(1) about date parsing.


# 1.17 20-Jan-1998 mycroft

Use TM_YEAR_BASE to adjust tm_year, not 1900.


# 1.16 05-Nov-1997 cgd

lint


# 1.15 19-Jul-1997 thorpej

branches: 1.15.2;
__RCSID()/__COPYRIGHT()/prototype police.


# 1.14 26-Mar-1997 cgd

pull in util.h rather than prototypeing logtwmp() locally.


# 1.13 24-Jan-1997 perry

remove obsolete -d and -t options -- kernel timezone handling is long gone


# 1.12 09-Jan-1997 tls

kill use of register


# 1.11 07-Sep-1995 jtc

Sync with 4.4lite2


# 1.10 23-Apr-1995 cgd

clean up RCS Ids slightly, etc.


# 1.9 21-Mar-1995 cgd

convert to new RCS id conventions.


# 1.8 22-Sep-1994 mycroft

Merge 4.4-Lite version.


# 1.7 31-Dec-1993 jtc

Minor tweaks.


# 1.6 16-Aug-1993 jtc

1003.2: 4.15.4: The output always shall be terminated by a newline character.


# 1.5 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.4 20-Jun-1993 deraadt

date comamnd ignored seconds value. patch from <mhw@cs.brown.edu>


# 1.3 22-Mar-1993 cgd

changed "Id" to "Header" for rcsids


# 1.2 22-Mar-1993 cgd

added rcs ids to all files


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.1.1.3 07-Sep-1995 jtc

imported from 44lite2


# 1.1.1.2 21-Sep-1994 mycroft

Import original 4.4-Lite version.


# 1.1.1.1 21-Mar-1993 cgd

initial import of 386bsd-0.1 sources


# 1.15.2.1 29-Jan-1998 mellon

Pull up 1.16 (cgd) and 1.17-1.21 (mycroft)


# 1.30.4.3 07-Jul-2001 gmcgarry

backout previous; wrong branch


# 1.30.4.2 07-Jul-2001 gmcgarry

setthetime() is prototyped as static; make it so.


# 1.30.4.1 09-Oct-2000 bjh21

Pull up revision 1.31 (approved by jhawk):
Fix off-by-one-hour bug when using date(1) to move between DST and non-DST.
Fixes PR#8750.


# 1.49.2.1 13-Jun-2010 riz

Pull up following revision(s) (requested by dholland in ticket #1396):
bin/date/date.c: revision 1.53
Don't blow up on date +''. Patch from Robert Elz in followup to PR 39392.


# 1.50.8.1 24-Mar-2008 keiichi

sync with head.


# 1.50.4.1 22-Mar-2008 matt

sync with HEAD


# 1.51.4.1 17-Sep-2008 wrstuden

Sync with wrstuden-revivesa-base-2.


# 1.52.4.1 20-Nov-2010 riz

Pull up following revision(s) (requested by dholland in ticket #1411):
bin/date/date.c: revision 1.53
Don't blow up on date +''. Patch from Robert Elz in followup to PR 39392.


# 1.57.2.1 08-Feb-2011 bouyer

Sync with HEAD