(t *testing.T)
| 492 | } |
| 493 | |
| 494 | func TestTimezoneOffsets(t *testing.T) { |
| 495 | t.Parallel() |
| 496 | |
| 497 | testCases := []struct { |
| 498 | Name string |
| 499 | Now time.Time |
| 500 | Loc *time.Location |
| 501 | ExpectedOffset int |
| 502 | }{ |
| 503 | { |
| 504 | Name: "UTC", |
| 505 | Loc: time.UTC, |
| 506 | ExpectedOffset: 0, |
| 507 | }, |
| 508 | |
| 509 | { |
| 510 | Name: "Eastern", |
| 511 | Now: time.Date(2021, 2, 1, 0, 0, 0, 0, time.UTC), |
| 512 | Loc: must(time.LoadLocation("America/New_York")), |
| 513 | ExpectedOffset: 5, |
| 514 | }, |
| 515 | { |
| 516 | // Daylight savings is on the 14th of March to Nov 7 in 2021 |
| 517 | Name: "EasternDaylightSavings", |
| 518 | Now: time.Date(2021, 3, 16, 0, 0, 0, 0, time.UTC), |
| 519 | Loc: must(time.LoadLocation("America/New_York")), |
| 520 | ExpectedOffset: 4, |
| 521 | }, |
| 522 | { |
| 523 | Name: "Central", |
| 524 | Now: time.Date(2021, 2, 1, 0, 0, 0, 0, time.UTC), |
| 525 | Loc: must(time.LoadLocation("America/Chicago")), |
| 526 | ExpectedOffset: 6, |
| 527 | }, |
| 528 | { |
| 529 | Name: "CentralDaylightSavings", |
| 530 | Now: time.Date(2021, 3, 16, 0, 0, 0, 0, time.UTC), |
| 531 | Loc: must(time.LoadLocation("America/Chicago")), |
| 532 | ExpectedOffset: 5, |
| 533 | }, |
| 534 | { |
| 535 | Name: "Ireland", |
| 536 | Now: time.Date(2021, 2, 1, 0, 0, 0, 0, time.UTC), |
| 537 | Loc: must(time.LoadLocation("Europe/Dublin")), |
| 538 | ExpectedOffset: 0, |
| 539 | }, |
| 540 | { |
| 541 | Name: "IrelandDaylightSavings", |
| 542 | Now: time.Date(2021, 4, 3, 0, 0, 0, 0, time.UTC), |
| 543 | Loc: must(time.LoadLocation("Europe/Dublin")), |
| 544 | ExpectedOffset: -1, |
| 545 | }, |
| 546 | { |
| 547 | Name: "HalfHourTz", |
| 548 | Now: time.Date(2024, 1, 20, 6, 0, 0, 0, must(time.LoadLocation("Asia/Yangon"))), |
| 549 | // This timezone is +6:30, but the function rounds to the nearest hour. |
| 550 | // This is intentional because our DAUs endpoint only covers 1-hour offsets. |
| 551 | // If the user is in a non-hour timezone, they get the closest hour bucket. |
nothing calls this directly
no test coverage detected