forked from pauldemarco/caldav-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
timezone.go
59 lines (46 loc) · 1.66 KB
/
timezone.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
package components
import (
"fmt"
"net/url"
"time"
"github.com/LeonidKrn/caldav-go/icalendar/values"
)
type TimeZone struct {
// defines the persistent, globally unique identifier for the calendar component.
Id string `ical:"tzid,required"`
// the location name, as defined by the standards body
ExtLocationName string `ical:"x-lic-location,omitempty"`
// defines a Uniform Resource Locator (URL) associated with the iCalendar object.
Url *values.Url `ical:"tzurl,omitempty"`
// specifies the date and time that the information associated with the calendar component was last revised in the
// calendar store.
// Note: This is analogous to the modification date and time for a file in the file system.
LastModified *values.DateTime `ical:"last-modified,omitempty"`
Daylight []*Daylight `ical:",omitempty"`
Standard []*Standard `ical:",omitempty"`
}
type Daylight struct {
DateStart *values.DateTime `ical:"dtstart,omitempty"`
RDates *values.RecurrenceDateTimes `ical:",omitempty"`
TzName string `ical:"tzname,omitempty"`
TzOffsetFrom string `ical:tzoffsetfrom,omitempty`
TzOffsetTo string `ical:tzoffsetto,omitempty`
}
func (*Daylight) EncodeICalTag() (string, error) {
return "DAYLIGHT", nil
}
type Standard Daylight
func (*Standard) EncodeICalTag() (string, error) {
return "STANDARD", nil
}
func NewDynamicTimeZone(location *time.Location) *TimeZone {
t := new(TimeZone)
t.Id = location.String()
t.ExtLocationName = location.String()
t.Url = values.NewUrl(url.URL{
Scheme: "http",
Host: "tzurl.org",
Path: fmt.Sprintf("/zoneinfo/%s", t.Id),
})
return t
}