timetable-extension #1

Open
fred.boniface wants to merge 160 commits from timetable-extension into main
2 changed files with 5 additions and 9 deletions
Showing only changes of commit 421b68f936 - Show all commits

View File

@ -10,13 +10,8 @@ import (
// Fetches the day string for the provided date.
func getDayString(t time.Time) string {
london, err := time.LoadLocation("Europe/London")
if err != nil {
log.Error("Unable to load time zone info", zap.Error(err))
}
timeNow := t.In(london)
day := timeNow.Weekday()
time := t.In(londonTimezone)
day := time.Weekday()
dayStrings := [...]string{"sun", "mon", "tue", "wed", "thu", "fri", "sat"}
@ -44,7 +39,6 @@ func isSameToday(t time.Time) bool {
// Returns how many days ago `t` was compared to today
func howManyDaysAgo(t time.Time) int {
log.Debug("Calculating how many days ago", zap.Time("Input time", t))
// Truncate both times to midnight in UTC timezone
today := time.Now().UTC().Truncate(24 * time.Hour)
input := t.UTC().Truncate(24 * time.Hour)
@ -89,7 +83,7 @@ func ParseCifDate(input *string, startOrEnd string) time.Time {
return time.Time{}
}
return t
return t.UTC()
}
// Parses CIF days_run field and converts to array of day strings

View File

@ -103,6 +103,8 @@ func TestParseCifDate(t *testing.T) {
for _, tc := range testCases {
result := ParseCifDate(&tc.dateString, tc.startOrEnd)
result = result.In(londonTimezone)
//fmt.Println(tc.dateString, "|UTC: ", result.In(time.UTC), "|EU/Lon: ", result)
if result != tc.expect {
t.Errorf("For datestring %s, startOrEnd %s, expected %s, but got %s", tc.dateString, tc.startOrEnd, tc.expect.Format(layout), result.Format(layout))
}