# Deal with timestamps using the date command function timestamp --wraps "date" --description "Return current unix timestamp" # Without argument it only prints the current timestamp if test (count $argv) -gt 0 # If the argument if help or --help or -h, it prints usage. if test "$argv[1]" = "--help" -o "$argv[1]" = "-h" -o "$argv[1]" = "help" echo -e "timestamp [TIMESTAMP]\n" echo "Print the current timestamp" echo "Pass a timestamp to get the corresponding date, so timestamp (timestamp) = date." else # Convert the argument to ISO 8601 date date --iso-8601=seconds -d @$argv[1] end else # The Unix timestamp is the number of seconds from 01 January 1970 (the unix epoch date) date "+%s" end end