forked from beevee/konturtransferbot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schedule.go
47 lines (37 loc) · 1.58 KB
/
schedule.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
package konturtransferbot
import "time"
// Schedule contains all information on transfer departure times
type Schedule struct {
WorkDayRouteToOffice Route
WorkDayRouteFromOffice Route
SaturdayRouteToOffice Route
SaturdayRouteFromOffice Route
}
// GetToOfficeText returns text representation of full schedule to office
func (s Schedule) GetToOfficeText(now time.Time) (string, string) {
prefix := "*Геологическая → Офис*\n\n"
suffix := "\nСубботний рейс в " + s.SaturdayRouteToOffice.String()
timeAgnosticRoute := prefix + s.WorkDayRouteToOffice.String() + suffix
if now.Weekday() == time.Saturday || now.Weekday() == time.Sunday {
return timeAgnosticRoute, ""
}
timeSensitiveRoute := prefix + s.WorkDayRouteToOffice.StringWithDivider(now) + suffix
if timeAgnosticRoute == timeSensitiveRoute {
return timeAgnosticRoute, ""
}
return timeSensitiveRoute, timeAgnosticRoute
}
// GetFromOfficeText returns text representation of full schedule from office
func (s Schedule) GetFromOfficeText(now time.Time) (string, string) {
prefix := "*Рейсы из офиса*\n\n"
suffix := "\nСубботний дежурный в " + s.SaturdayRouteFromOffice.String()
timeAgnosticRoute := prefix + s.WorkDayRouteFromOffice.String() + suffix
if now.Weekday() == time.Saturday || now.Weekday() == time.Sunday {
return timeAgnosticRoute, ""
}
timeSensitiveRoute := prefix + s.WorkDayRouteFromOffice.StringWithDivider(now) + suffix
if timeAgnosticRoute == timeSensitiveRoute {
return timeAgnosticRoute, ""
}
return timeSensitiveRoute, timeAgnosticRoute
}