-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDayofWeekCalculator.sh
71 lines (64 loc) · 1.87 KB
/
DayofWeekCalculator.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
#!/bin/bash
########################################################################
# Day of the Week Calculator #
########################################################################
# Sinwindie #
########################################################################
# Program will prompt the user for a date in the yyymmdd format and #
# return the date to the user and provide what day of the week the #
# provided date falls on. #
########################################################################
# Last Updated: January 6, 2019 #
########################################################################
clear
#Clears terminal screen
echo "Welcome to the date to day of the week calculator."
echo "Enter any date to determine what day of the week it falls on,"
read -p "Enter a date in yyyymmdd format to begin: " input
# Obtains input from user
DoW=$(date -d $input +%A)
#Uses input to determine day of week
year="${input:0:4}"
month="${input:4:2}"
day="${input:6:2}"
#Breaks up input to year, month, and days
if [ $month == 01 ]
then
strmonth="January"
elif [ $month == 02 ]
then
strmonth="February"
elif [ $month == 03 ]
then
strmonth="March"
elif [ $month == 04 ]
then
strmonth="April"
elif [ $month == 05 ]
then
strmonth="May"
elif [ $month == 06 ]
then
strmonth="June"
elif [ $month == 07 ]
then
strmonth="July"
elif [ $month == 08 ]
then
strmonth="August"
elif [ $month == 08 ]
then
strmonth="September"
elif [ $month == 10 ]
then
strmonth="October"
elif [ $month == 11 ]
then
strmonth="November"
elif [ $month == 12 ]
then
strmonth="December"
fi
#Assigns string of month based on user input
echo -n "$strmonth $day, $year falls on a $DoW."
#Prints results to screen