-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatesh
executable file
·57 lines (51 loc) · 1.94 KB
/
datesh
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
#!/usr/bin/env bash
#
# ############################################################################
# Project: scripts (none)
# File...: datesh
# Created: Friday, 20/09/2019-01:13:35
# Author.: @fbnmtz, ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Saturday, 2023/06/10 - 22:11:01
# Modified By..: @fbnmtz, ([email protected])
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.1.2.21
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
# ############################################################################
# HISTORY:
#
default_format="+%Y/%m/%d-%H:%M:%S"
while [ "$1" != "" ]; do
# flags -f -D -T
# date formats: -br -us
case "$1" in
# str formated to be used in filenames (sub '/',':' for '.')
-f | --formated)
filename_format="| tr -d ' ' | tr -s ',' '.' | tr -s '/' '.' | tr -s ':' '.'" ;;
# return only date
-D | --date)
cut_date_or_time="| tr -d ' ' | cut -d '-' -f1" ;;
# return only time
-T | --time)
cut_date_or_time="| tr -d ' ' | cut -d '-' -f2" ;;
# US format
-us) args="+%Y/%m/%d-%H:%M:%S" ;;
# BR format
-br) args="+%d/%m/%Y-%H:%M:%S" ;;
# header format (for bins header comment)
-hr|--header) args="+%A, %Y/%m/%d - %H:%M:%S" ;;
# date parts
-y) args="+%y" ;; # year (xx)
-Y) args="+%Y" ;; # year (xxxx)
-m) args="+%m" ;; # month
-d) args="+%d" ;; # day
# default format
*) args="$default_format"
esac
shift
done
# set format when no arg given
[ -z "$args" ] && args="$default_format"
eval "date \"$args\"" $cut_date_or_time $filename_format