-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmdate
More file actions
executable file
·89 lines (76 loc) · 4.04 KB
/
Copy pathmdate
File metadata and controls
executable file
·89 lines (76 loc) · 4.04 KB
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
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
#
# ############################################################################
# Project: scripts (none)
# File...: mdate
# Created: Thursday, 2020/10/01 - 12:52:37
# Author.: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Monday, 2026/08/24 - 23:51:39
# Modified By..: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.3.6.349
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
# ############################################################################
# HISTORY:
#
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
# shellcheck disable=SC1090
source "$xSHELL_INIT"
use args colors
xrequirements date
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
date_separator="/"
time_separator=":"
# blocks of code
__date="args+=\"%d/%m/%Y\""
__day="args+=\"%d\""
__month="args+=\"%m\""
__year="args+=\"%Y\""
__year2="args+=\"%y\""
__mfull="args+=\"%B\""
__mshort="args+=\"%b\""
__time="args+=\"%H$time_separator%M$time_separator%S\""
__hour="args+=\"%H\""
__minutes="args+=\"%M\""
__seconds="args+=\"%S\""
__us="args+=\"%Y$date_separator%m$date_separator%d-%H$time_separator%M$time_separator%S\""
__br="args+=\"%d$date_separator%m$date_separator%Y-%H$time_separator%M$time_separator%S\""
__char="shift; .xs --require-value "\$1" "char" ; char="\$1"; args+=\"\$char\""
__header="args+=\"%A, %d/%m/%Y - %H:%M:%S\""
__header_en="export LC_TIME=en_US.UTF-8 2>/dev/null; args+=\"%A, %Y/%m/%d - %H:%M:%S\""
__weekday="args+=\"%A\""
__weekday_en="export LC_TIME=en_US.UTF-8 2>/dev/null; args+=\"%A\""
__filename="args=\"%Y%m%d-%H%M%S\""
__default_args="%d$date_separator%m$date_separator%Y-%H$time_separator%M$time_separator%S"
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~
xarg --block "Date Options"
xarg --id -D,--date --code "$__date" --desc "current date (dd/mm/YYYY)"
xarg --id -d,--day --code "$__day" --desc "current day (dd)"
xarg --id -m,--month --code "$__month" --desc "current month (mm)"
xarg --id -y,--year,--year4 --code "$__year" --desc "current year (YYYY)"
xarg --id -Y,--year2 --code "$__year2" --desc "current year (YY)"
xarg --id -n,--mfull --code "$__mfull" --desc "current month (full name)"
xarg --id -N,--mshort --code "$__mshort" --desc "current month (short name)"
xarg --block "Time Options"
xarg --id -t,--time --code "$__time" --desc "current time (HH:MM:SS)"
xarg --id -H,--hour --code "$__hour" --desc "current hour (HH)"
xarg --id -M,--minutes --code "$__minutes" --desc "current minute (MM)"
xarg --id -s,--seconds --code "$__seconds" --desc "current second (SS)"
xarg --block "General Options"
xarg --id -c,--char --code "$__char" --desc "add custom <char> to output"
xarg --id -u,--us --code "$__us" --desc "full date (YYYY/mm/dd-HH:MM:SS)"
xarg --id -b,--br --code "$__br" --desc "full date (dd/mm/YYYY-HH:MM:SS)"
xarg --id -r,--header --code "$__header" --desc "full date for header"
xarg --id -R,--header-en --code "$__header_en" --desc "full date for header (us format)"
xarg --id -w,--weekday --code "$__weekday" --desc "weekday name"
xarg --id -W,--weekday-en --code "$__weekday_en" --desc "weekday name (us format)"
xarg --id -f,--filename --code "$__filename" --desc "full date formated for filename (YYYYmmdd-HHMMSS)"
xarg --header "helper to get date/time in many formats"
xarg --footer " \`-> options can be combined to get a custom output, for example: '$APP_NAME -dmy' will return 'ddmmYYYY'"
xrun --xreject-unknown --xversionrc "$@"
[ -z "$args" ] && args=$__default_args
# run date command with custom args
date "+$args"