Display timestamp in ISO 8601 format.
- POSIX shell
- POSIX-compliant commands
- GNU Date (GNU Core Utilities)
- To use
%N
format (nano seconds)
- To use
-
Clone this repository.
-
Make the command available. For example, there are three different ways:
-
Copy file
cd path/to/tiso # Cloned repository install_file=/usr/local/bin/tiso # Can be changed sudo cp bin/tiso "$install_file" sudo chmod +x "$install_file"
Uninstall:
install_file=/usr/local/bin/tiso # Can be changed sudo rm "$install_file"
-
Symbolic link
cd path/to/tiso # Cloned repository symlink_file=/usr/local/bin/tiso # Can be changed sudo ln -s "$(pwd)/bin/tiso" "$symlink_file"
Uninstall:
symlink_file=/usr/local/bin/tiso # Can be changed sudo rm "$symlink_file"
-
Alias
-
Open rc file in editor. (
~/.bashrc
for bash,~/.zshrc
for zsh) -
Add an alias of
bin/tiso
to the file.alias tiso="path/to/bin/tiso"
Uninstall:
Remove the alias from the file.
-
-
tiso [options...]
Name | Description |
---|---|
-b |
Use basic format |
-e |
Use extended format (default) |
Name | Description |
---|---|
-C |
Display calendar dates (default) |
-W |
Display week dates |
-O |
Display ordinal dates |
Name | Description |
---|---|
-Y |
Display in years |
-m |
Display in months |
-w |
Display in weeks |
-d |
Display in days |
-H |
Display in hours |
-M |
Display in minutes |
-S |
Display in seconds (default) |
Name | Description |
---|---|
-p <digits> |
Specify decimal precision (default: 0) |
-0, -1, ..., -9 |
Shortcut for precision |
-f |
Use a dot for the decimal separator (default) |
-c |
Use a comma for the decimal separator |
Name | Description |
---|---|
-i |
Do not show time zone (default) |
-z |
Show time zone in minutes |
-Z |
Show time zone in hours |
-l |
Do not set time zone to UTC (default) |
-u |
Set time zone to UTC |
-U |
Set time zone to UTC with 'Z' designator |
-s <sign> |
Specify the type of minus sign for the time zone (default: -) |
Name | Description |
---|---|
-n |
Suppress new line |
-N |
Do not suppress new line (default) |
-D <command> |
Specify a custom date command |
Name | Description |
---|---|
-v |
Show version |
-h |
Show help |
Name | Description |
---|---|
TZ |
Set time zone if the -u or -U flag is not specified |
$ tiso
2012-03-04T12:34:56
$ tiso -b
20120304T123456
$ tiso -W
2012-W09-7T12:34:56
$ tiso -O
2012-064T12:34:56
$ tiso -d
2012-03-04
$ tiso -3
2012-03-04T12:34:56.123
$ tiso -p 10
2012-03-04T12:34:56.1234567890
$ tiso -c3
2012-03-04T12:34:56,123
$ tiso -z
2012-03-04T12:34:56-05:00
$ tiso -Z
2012-03-04T12:34:56-05
$ tiso -u
2012-03-04T17:34:56
$ tiso -U
2012-03-04T17:34:56Z
# U+2212 is MINUS SIGN
$ tiso -s $'\u2212' -z
2012-03-04T12:34:56−05:00
$ tiso -n
2012-03-04T12:34:56$
$ tiso -D 'date -d "1972-12-16"'
1972-12-16T00:00:00
$ alias tiso_utc="tiso -U3"
$ tiso_utc
2012-03-04T17:34:56.123Z
# If `gdate` is in the PATH
shellspec
# If `date` command is GNU Date, e.g. if you are using GNU/Linux
GNU_DATE=date shellspec
# Otherwise
GNU_DATE=path/to/gnu_date shellspec
shellcheck **/*.sh bin/*