Skip to content

Commit

Permalink
Empty timezone is UTC assumed for compatibility reasons with 'TestSet…
Browse files Browse the repository at this point in the history
…Duration' due to the way time.Parse(time.RFC822Z, time.RFC822Z) works
  • Loading branch information
arran4 committed Oct 28, 2024
1 parent 7151e71 commit 14d7e7c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions components.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func dateFormatForTime(t time.Time, props []PropertyParameter) (string, []Proper
if l != nil {
ls = l.String()
}
if (l == time.UTC /* || ls == "MST"*/ || l == nil) && tzid == nil {
if (l == time.UTC /* || ls == "MST"*/ || ls == "") && tzid == nil {
layout = icalDateFormatUTC
} else if tzid == nil && l != time.Local /* && ls != "MST"*/ {
props = append(props, WithTZID(ls))
Expand All @@ -213,7 +213,7 @@ func timestampFormatForTime(t time.Time, props []PropertyParameter) (string, []P
if l != nil {
ls = l.String()
}
if (l == time.UTC || /*ls == "MST" ||*/ l == nil) && tzid == nil {
if (l == time.UTC || /*ls == "MST" ||*/ ls == "") && tzid == nil {
layout = icalTimestampFormatUTC
} else if tzid == nil && l != time.Local /* && ls != "MST"*/ {
props = append(props, WithTZID(ls))
Expand Down
4 changes: 2 additions & 2 deletions components_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestSetDuration(t *testing.T) {
date, _ := time.Parse(time.RFC822, time.RFC822)
date, _ := time.Parse(time.RFC822Z, time.RFC822Z)
duration := time.Duration(float64(time.Hour) * 2)

testCases := []struct {
Expand Down Expand Up @@ -181,7 +181,7 @@ END:VEVENT
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {

if dateSpecificLocationNotLocal.Location().String() == "MST" {
if tc.start.Location().String() == "MST" || tc.end.Location().String() == "MST" {
t.Skipf("No idea why we are getting MST -- Help?")
}

Expand Down

0 comments on commit 14d7e7c

Please sign in to comment.