-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdate
executable file
·78 lines (65 loc) · 4.32 KB
/
mdate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env bash
#
# ############################################################################
# Project: scripts (none)
# File...: mdate
# Created: Thursday, 2020/10/01 - 12:52:37
# Author.: @fbnmtz, ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Monday, 2024/12/09 - 17:39:53
# Modified By..: @fbnmtz, ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.3.4.236
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
# ############################################################################
# HISTORY:
#
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
# shellcheck disable=SC1090
source "$xSHELL_INIT"
use args
xrequirements date
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
date_separator="/"
time_separator=":"
updateArgs(){ echo "%d$date_separator%m$date_separator%Y-%H$time_separator%M$time_separator%S" ; }
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
# xarg --id -S,--separator --code "shift; if [ -n \"$1\" ]; then date_separator=$1; else args=$(updateArgs); fi;" --desc "separator used in date"
# xarg --id -D,--sep-date --var date_char+r,type:date --desc "separator used in date"
# xarg --id -T,--sep-time --var time_char+r,type:time --desc "separator used in time"
# xarg --id -c,--char --var char+r --code "args+=$char" --desc "separator used in time"
# xarg --id -c,--char --code "shift; requireARG $1; args+=$1" --desc "separator used in time"
xarg --block "Date Options"
xarg --id -d,--day --code "args+=\"%d\"" --desc "current day (number)"
xarg --id -m,--month --code "args+=\"%m\"" --desc "current month (number)"
xarg --id -y,--year --code "args+=\"%Y\"" --desc "current year (number)"
xarg --id -Y,--year2 --code "args+=\"%y\"" --desc "current year (two digits)"
xarg --id -D,--date --code "args+=\"%d/%m/%Y\"" --desc "current date (full)"
xarg --block "Time Options"
xarg --id -H,--hour --code "args+=\"%H\"" --desc "current hour (number)"
xarg --id -M,--minutes --code "args+=\"%M\"" --desc "current minutes (number)"
xarg --id -s,--seconds --code "args+=\"%S\"" --desc "current seconds (number)"
xarg --id -t,--time --code "args+=\"%H$time_separator%M$time_separator%S\"" --desc "current time (H M S)"
xarg --block "General Options"
# xarg --id -c,--char --code "[ -n "\$2" ] && { shift ; char="\$1" ; } " --desc "char separator"
xarg --id -u,--us --code "args+=\"%Y$date_separator%m$date_separator%d-%H$time_separator%M$time_separator%S\" " --desc "full date in US format"
xarg --id -b,--br --code "args+=\"%d$date_separator%m$date_separator%Y-%H$time_separator%M$time_separator%S\" " --desc "full date in BR format"
xarg --id -r,--header --code "args+=\"%A, %d/%m/%Y - %H:%M:%S\"" --desc "date/time for header"
xarg --id -R,--header-en --code "export LC_TIME=en_US.UTF-8 2>/dev/null; args+=\"%A, %Y/%m/%d - %H:%M:%S\"" --desc "date/time for header (us format)"
xarg --id -w,--weekday --code "args+=\"%A\"" --desc "current weekday (name)"
xarg --id -W,--weekday-en --code "export LC_TIME=en_US.UTF-8 2>/dev/null; args+=\"%A\"" --desc "current weekday (name) (us format)"
xarg --id -f,--for-filename --code "args=\"%Y%m%d-%H%M%S\"" --desc "full date formated for filename"
xarg --header "helper to get date in many formats"
# [ "$type" == "date" ] && { date_separator=$date_char; } #args=$(updateArgs); }
# [ "$type" == "time" ] && { time_separator=$time_char; } #args=$(updateArgs); }
xrun --xreject-unknow --xrequire-one --xversionrc --xcolors "$@"
# if [ -n "$char" ]; then
# date_separator="$char"
# time_separator="$char"
# args=$(updateArgs)
# fi
[ -z "$args" ] && args=$(updateArgs)
# run date command with custom args
date "+$args"