-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweekdays.go
63 lines (55 loc) · 1.22 KB
/
weekdays.go
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
package weekdays
import (
"fmt"
"time"
)
const (
messageWeekday = "Its the weekday!"
messageWeekend = "Its the weekend!"
messageWeekdayShort = "weekday!"
messageWeekendShort = "weekend!"
)
// return true if its the weekday, else return false
func IsWeekday() bool {
switch time.Now().Weekday() {
case time.Saturday, time.Sunday:
return false
default:
return true
}
}
// return true if its the weekend, else return false
func IsWeekend() bool {
switch time.Now().Weekday() {
case time.Saturday, time.Sunday:
return true
default:
return false
}
}
// return a different message depending on whether its the weekday or the weekend
func Message() string {
switch time.Now().Weekday() {
case time.Saturday, time.Sunday:
return messageWeekend
default:
return messageWeekday
}
}
// similar to Message(), but the returned message are shorter
func MessageShort() string {
switch time.Now().Weekday() {
case time.Saturday, time.Sunday:
return messageWeekendShort
default:
return messageWeekdayShort
}
}
// print the returned message from Message()
func PrintMessage() {
fmt.Println(Message())
}
// print the returned message from MessageShort()
func PrintMessageShort() {
fmt.Println(MessageShort())
}