This repository has been archived by the owner on Apr 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_date.sh
96 lines (94 loc) · 1.43 KB
/
check_date.sh
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
90
91
92
93
94
95
96
clear
touch t
echo "This program checks date"
if [ $# -eq 1 ]
then
echo $1 > t
awk 'BEGIN{
FS="/" }
{
if(NF==3)
{
if($1>0 && $1<13)
{
if($2>0 && $2<32)
{
if($1!=2)
{
if($1==4 || $1==6 || $1==9 || $1==11)
{
if($2>30)
{
print "Invalid Day"
exit
}
}
if($3%4==0 && $3%100!=0)
{
print "Leap Yaer"
}
else if($3%4==0 && $3%100==0)
{
if($3%400==0)
{
print "Leap Yaer"
}
}
print $0
system("date -d "$0" +%A")
system("date -d "$0" +%B")
}
else
{
if($2<30)
{
if($3%4==0 && $3%100!=0)
{
print "Leap Yaer"
}
else if($3%4==0 && $3%100==0)
{
if($3%400==0)
{
print "Leap Yaer"
}
}
else
{
if($2>28)
{
print "Invalid day"
exit
}
}
print $0
system("date -d "$0" +%A")
system("date -d "$0" +%B")
}
else
{
print "Invalid Day"
}
}
}
else
{
print "invalid Day"
}
}
else
{
print "Invalid Month"
if($2>31)
print "Invalid day"
}
}
else
{
print "Wrong Input"
}
}' t
else
echo "Invalid date"
fi
rm t