1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:38:13 +00:00

date: Allow using a custom format string

This commit adds an optional string positional argument which is used a
custom format string for the date.
This commit is contained in:
Daniel Bertalan 2022-02-25 21:40:28 +01:00 committed by Linus Groh
parent 01dc718f07
commit 7bd68c86d3
2 changed files with 21 additions and 6 deletions

View file

@ -5,7 +5,7 @@ date - print or set the system date and time
## Synopsis
```**sh
$ date [--set date] [--unix] [--iso-8601] [--rfc-3339] [--rfc-5322]
$ date [--set date] [--unix] [--iso-8601] [--rfc-3339] [--rfc-5322] [format-string]
```
## Description
@ -21,12 +21,19 @@ or print the system date and time in various formats.
* `-r`, `--rfc-3339`: Print date in RFC 3339 format
* `-R`, `--rfc-5322`: Print date in RFC 5322 format
## Arguments
* `format-string`: Custom format to print the date in. Must start with a '+' character.
## Examples
```sh
# Print the current date and time in ISO 8601 format
$ date --iso-8601
# Print the current date in a custom format
$ date +%Y-%m-%d
# Set date to 1610017485 (UNIX time)
$ date -s 1610017485
```