Skip to content

Datetime and Unix time conversion functions for POSIX shells

License

Notifications You must be signed in to change notification settings

ko1nksm-shlab/sh-datetime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sh-datetime

Datetime and Unixtime conversion functions for POSIX shells.

Requirement

  • Any POSIX shell (sh, bash, ksh, zsh, etc)
  • date command for unixtime function (No +%s format support required)

Usage

unixtime v
echo "$v" # => 1714860198 (UTC)

unixtime v -local
echo "$v" # => 1714892598 (local)

unixtime2datetime v "$v"
echo "$v" # => 2024-05-05T07:03:18

datetime2unixtime v "$v"
echo "$v" # => 1714892598

last_day_of_month v "2000-02"
echo "$v" # => 2000-02-29
last_day_of_month v "2001-02"
echo "$v" # => 2001-02-28
last_day_of_month v "2004-02"
echo "$v" # => 2004-02-29
last_day_of_month v "2100-02"
echo "$v" # => 2100-02-28
echo

echo "=== weekday ==="
weekday v "2024-05-05"
echo "$v" => sun:7

About

Datetime and Unix time conversion functions for POSIX shells

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages