mirror of
https://github.com/armbian/bash-util.git
synced 2026-01-06 10:37:49 -08:00
date.sh: clean up date::now
This commit is contained in:
14
src/date.sh
14
src/date.sh
@@ -3,23 +3,23 @@
|
||||
# @file Date
|
||||
# @brief Functions for manipulating dates.
|
||||
|
||||
# @description Get current time in unix timestamp.
|
||||
# @description Get current time as unix timestamp.
|
||||
#
|
||||
# @example
|
||||
# echo "$(date::now)"
|
||||
# date::now
|
||||
# #Output
|
||||
# 1591554426
|
||||
#
|
||||
# @noargs
|
||||
#
|
||||
# @exitcode 0 If successful.
|
||||
# @exitcode 0 If successful.
|
||||
# @exitcode 1 If unable to generate timestamp.
|
||||
#
|
||||
# @stdout current timestamp.
|
||||
# @stdout Current timestamp.
|
||||
date::now() {
|
||||
local now
|
||||
now="$(date --universal +%s)" || return $?
|
||||
printf "%s" "${now}"
|
||||
local ts
|
||||
ts="$(date --universal +%s)" || return
|
||||
printf "%s" "$ts"
|
||||
}
|
||||
|
||||
# @description convert datetime string to unix timestamp.
|
||||
|
||||
Reference in New Issue
Block a user