commit: 1ee2658a5408ffbec042897872af4a5f26047e4c
parent c61a0810b88816e7c0462a01c0b795d58f948ffb
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Mon, 19 May 2025 22:56:50 +0200
oasis 85859adaeb
Diffstat:
4 files changed, 373 insertions(+), 0 deletions(-)
diff --git a/bin/date b/bin/date
Binary files differ.
diff --git a/bin/touch b/bin/touch
Binary files differ.
diff --git a/share/man/man1/date.1 b/share/man/man1/date.1
@@ -0,0 +1,225 @@
+.\" utils-std: Collection of commonly available Unix tools
+.\" Copyright 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+.\" SPDX-License-Identifier: MPL-2.0
+.Dd April 6, 2025
+.Dt DATE 1
+.Os
+.Sh NAME
+.Nm date
+.Nd display date and time
+.Sh SYNOPSIS
+.Nm
+.Op Fl jRu
+.Op Fl I Ar iso_fmt
+.Op Fl d Ar datetime | Fl r Ar epoch
+.Op Cm + Ns Ar format
+.Nm
+.Op Fl jRu
+.Op Fl I Ar iso_fmt
+.Ar mmddHHMM Ns Oo Oo Ar CC Oc Ns Ar yy Oc
+.Op Cm + Ns Ar format
+.Nm
+.Op Fl jRu
+.Op Fl I Ar iso_fmt
+.Fl f Ar now_format
+.Ar now
+.Op Cm + Ns Ar format
+.Sh DESCRIPTION
+When
+.Nm
+is invoked without arguments it displays the current datetime
+Otherwise, depending on the options specified,
+will print the datetime in a user-defined way.
+.Sh OPTIONS
+.Bl -tag -width Ds
+.It Fl d Ar datetime
+Use
+.Ar datetime
+instead of current datetime.
+.\" utils-std: Collection of commonly available Unix tools
+.\" Copyright 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+.\" SPDX-License-Identifier: MPL-2.0
+.\"
+.\" Example:
+.\" .Fl d Ar datetime
+.\" .so lib/datetime_parse.mdoc
+.\"
+Should be formatted either with a leading @ (at) symbol followed by
+the Unix timestamp (number of seconds before and after 1970-01-01 00:00:00Z),
+for example
+.Ql @1698791420
+corresponds to 2023-10-31 23:30:20 UTC
+.Pp
+Or as Email / "Internet Message Format" (RFC5322, RFC2822, RFC822), for example:
+.Bl -bullet -compact
+.It
+.Ql Fri, 21 Nov 1997 09:55:06 -0600
+.It
+.Ql 21 Nov 97 09:55:06 GMT
+.El
+.Pp
+Or an
+.Xr asctime 3 Ns -like
+format, for example:
+.Ql Sun Sep 16 01:03:52 1973
+.Pp
+Or as RFC3339 which looks like
+.Ql YYYY-MM-DDThh:mm:SS[frac][tz] ,
+where:
+.Bl -tag -width Ds
+.It Ql YYYY-MM-DD
+Corresponds to %Y-%m-%d of
+.Xr strptime 3 .
+.It Ql T
+Is either
+.Ql T
+or a space.
+.It Ql [frac]
+Is either empty, or fractional seconds starting with either a comma
+.Pq \&,
+or a period
+.Pq \&. .
+.It Ql [tz]
+When empty it corresponds to local time.
+Otherwise it can be an UTC offset in the format
+.Ql [+-]HH:?MM
+or the letter
+.Qq Z ,
+signifying UTC.
+.El
+.Pp
+Some examples:
+.Bl -bullet -compact
+.It
+.Ql 2003-06-02T13:37:42.713Z
+.It
+.Ql 1971-01-02T03:04:05.678+0900
+.El
+.It Fl f Ar now_format
+Use
+.Ar now_format
+as the
+.Xr strptime 3
+format string for
+.Ar now ,
+which will be used instead of the current datetime.
+.It Fl I Ar iso_fmt
+Set the ISO-8601 resolution to format at with setting
+.Ar iso_fmt
+to one of the following values:
+.Bl -tag -width m_inutes_
+.It Ar d Ns Op Ar ate
+date, equivalent to +%Y-%m-%d
+.It Ar h Ns Op Ar ours
+hours, equivalent to +%Y-%m-%dT%H%:z
+.It Ar m Ns Op Ar inutes
+minutes, equivalent to +%Y-%m-%dT%H:%M%:z
+.It Ar s Ns Op Ar econds
+seconds, equivalent to +%Y-%m-%dT%H:%M:%S%:z
+.It Ar n Ns Op Ar s
+nano-seconds, equivalent to +%Y-%m-%dT%H:%M:%S,%N%:z
+.El
+.It Fl j
+Do no set the system date.
+This allows to use the
+.Fl f
+flag to convert one datetime to another.
+.It Fl u
+Use UTC (coordinated universal time) instead of the local time.
+.It Fl r Ar epoch
+Use
+.Ar epoch
+(seconds relative to 1970-01-01 00:00:00 UTC)
+instead of current datetime.
+.It Fl R
+Set the default value of
+.Ar format
+to match RFC5322 (Email / Internet Message Format).
+.It Ar mmddHHMM Ns Oo Oo Ar CC Oc Ns Ar yy Oc
+Sets custom datetime, if
+.Fl j
+isn't set, the system time is also set.
+.Pp
+Each letters corresponds to:
+.Bl -tag -width mm -compact
+.It mm
+months aka %m
+.It dd
+days aka %d
+.It HH
+hours aka %H
+.It MM
+minutes aka %M
+.It CC
+centuries aka %C
+.It yy
+century-less years aka %y
+.El
+.Pp
+For example 072505542024 corresponds to 2024-07-25T05:54,
+as you can verify with the following command:
+.Dl date -j 072505542024 +%Y-%m-%dT%H:%M
+.It Cm + Ns Ar format
+Set the displayed datetime in
+.Xr strftime 3
+format,
+with additionally
+%N for nanoseconds and %:z for colon-separated timezone (±ZZ:ZZ).
+.br
+Otherwise defaults to
+.Ql %c
+.El
+.Sh ENVIRONMENT
+Look at the manual page of
+.Xr strftime 3
+for the environment variables, typical ones are
+.Ev TZ ,
+.Ev LC_TIME
+and
+.Ev LC_ALL
+but this depends on your system.
+.Sh EXIT STATUS
+.Ex -std
+.Sh SEE ALSO
+.Xr clock_settime 3 ,
+.Xr strftime 3
+.Sh STANDARDS
+.Nm
+should be compliant with the
+IEEE Std 1003.1-2024 (“POSIX.1”)
+specification.
+.Pp
+The
+.Fl d
+and
+.Fl R
+options are present for compatibility with other modern systems such as
+NetBSD, BusyBox, and GNU coreutils.
+.br
+The
+.Fl r
+option is inspired from BSD and illumos,
+.Fl f
+and
+.Fl j
+options are inspired by FreeBSD and NetBSD.
+.Pp
+The %N and %:z formats are extensions inspired from GNU coreutils.
+.Pp
+The
+.Fl I
+option was added for compatibility with GNU coreutils, BusyBox, FreeBSD 12.0+.
+.Sh HISTORY
+The
+.Fl R ,
+.Fl d ,
+.Fl f ,
+.Fl j ,
+and
+.Fl r
+options were present in utils-std 0.0.1.
+The
+.Fl I
+option and %N and %:z formats were added in utils-std 0.0.2.
+.Sh AUTHORS
+.An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me
diff --git a/share/man/man1/touch.1 b/share/man/man1/touch.1
@@ -0,0 +1,148 @@
+.\" utils-std: Collection of commonly available Unix tools
+.\" Copyright 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+.\" SPDX-License-Identifier: MPL-2.0
+.Dd 2023-06-03
+.Dt TOUCH 1
+.Os
+.Sh NAME
+.Nm touch
+.Nd change file access and modification times
+.Sh SYNOPSIS
+.Nm
+.Op Fl acfhm
+.Op Fl d Ar isotime | Fl t Ar datetime | Fl r Ar ref_file
+.Ar file...
+.Sh DESCRIPTION
+.Nm
+changes the date modification and access times on each
+.Ar file
+it is given.
+.Bl -tag -width Ds
+.It Fl a
+Change the access time, no changes to modification time unless
+.Fl m
+is also given.
+.It Fl c
+Do not create
+.Ar file .
+.It Fl f
+Ignored.
+coreutils and BusyBox never supported it,
+.Ox
+removed it in 2005,
+.Nx
+in 2011,
+.Fx
+in 2012.
+.\" Let's not publicly document too much that illumos still supports it
+.It Fl d Ar isotime
+.\" utils-std: Collection of commonly available Unix tools
+.\" Copyright 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+.\" SPDX-License-Identifier: MPL-2.0
+.\"
+.\" Example:
+.\" .Fl d Ar datetime
+.\" .so lib/datetime_parse.mdoc
+.\"
+Should be formatted either with a leading @ (at) symbol followed by
+the Unix timestamp (number of seconds before and after 1970-01-01 00:00:00Z),
+for example
+.Ql @1698791420
+corresponds to 2023-10-31 23:30:20 UTC
+.Pp
+Or as Email / "Internet Message Format" (RFC5322, RFC2822, RFC822), for example:
+.Bl -bullet -compact
+.It
+.Ql Fri, 21 Nov 1997 09:55:06 -0600
+.It
+.Ql 21 Nov 97 09:55:06 GMT
+.El
+.Pp
+Or an
+.Xr asctime 3 Ns -like
+format, for example:
+.Ql Sun Sep 16 01:03:52 1973
+.Pp
+Or as RFC3339 which looks like
+.Ql YYYY-MM-DDThh:mm:SS[frac][tz] ,
+where:
+.Bl -tag -width Ds
+.It Ql YYYY-MM-DD
+Corresponds to %Y-%m-%d of
+.Xr strptime 3 .
+.It Ql T
+Is either
+.Ql T
+or a space.
+.It Ql [frac]
+Is either empty, or fractional seconds starting with either a comma
+.Pq \&,
+or a period
+.Pq \&. .
+.It Ql [tz]
+When empty it corresponds to local time.
+Otherwise it can be an UTC offset in the format
+.Ql [+-]HH:?MM
+or the letter
+.Qq Z ,
+signifying UTC.
+.El
+.Pp
+Some examples:
+.Bl -bullet -compact
+.It
+.Ql 2003-06-02T13:37:42.713Z
+.It
+.Ql 1971-01-02T03:04:05.678+0900
+.El
+.It Fl h
+Do not follow symlinks.
+.It Fl m
+Change the modification time, no changes to access time unless
+.Fl a
+is also given.
+.It Fl t Ar datetime
+Use the specified
+.Ar datetime
+instead of the current time, with the form
+.Oo Oo CC Oc Ns YY Oc Ns MMDDhhmm Ns Oo \.SS Oc
+where:
+.Bl -tag -width _MMDDhhmm_
+.It Ql CC
+Corresponds to the first 2 digits of the year, aka %C
+.It Ql YY
+Corresponds to the last 2 digits of the year, aka %y
+.It Ql MMDDhhmm
+Corresponds to month, day, hours, minutes aka %m%d%H%M
+.It Ql .SS
+Corresponds to the seconds
+.El
+.Pp
+For example:
+.Ql 200306021337.42
+.It Fl r Ar ref_file
+Use the corresponding times of the file at
+.Ar ref_file
+instead of the current time.
+.El
+.Sh EXIT STATUS
+.Ex -std
+Note: Will exit with failure when
+.Fl c
+is given but the file doesn't exists.
+.Sh SEE ALSO
+.Xr stat 1 ,
+.Xr futimens 3 ,
+.Xr strptime 3
+.Sh STANDARDS
+.Nm
+should be compliant with the
+IEEE Std 1003.1-2024 (“POSIX.1”)
+specification.
+.Pp
+.Fl h
+and
+.Fl f
+are extensions.
+.Sh AUTHORS
+.An Haelwenn (lanodan) Monnier Aq Mt contact+utils@hacktivis.me