1 package internal
2 3 import "time"
4 5 // Timezones used for local datetime, date, and time TOML types.
6 //
7 // The exact way times and dates without a timezone should be interpreted is not
8 // well-defined in the TOML specification and left to the implementation. These
9 // defaults to current local timezone offset of the computer, but this can be
10 // changed by changing these variables before decoding.
11 //
12 // TODO:
13 // Ideally we'd like to offer people the ability to configure the used timezone
14 // by setting Decoder.Timezone and Encoder.Timezone; however, this is a bit
15 // tricky: the reason we use three different variables for this is to support
16 // round-tripping – without these specific TZ names we wouldn't know which
17 // format to use.
18 //
19 // There isn't a good way to encode this right now though, and passing this sort
20 // of information also ties in to various related issues such as string format
21 // encoding, encoding of comments, etc.
22 //
23 // So, for the time being, just put this in internal until we can write a good
24 // comprehensive API for doing all of this.
25 //
26 // The reason they're exported is because they're referred from in e.g.
27 // internal/tag.
28 //
29 // Note that this behaviour is valid according to the TOML spec as the exact
30 // behaviour is left up to implementations.
31 var (
32 localOffset = func() int { _, o := time.Now().Zone(); return o }()
33 LocalDatetime = time.FixedZone("datetime-local", localOffset)
34 LocalDate = time.FixedZone("date-local", localOffset)
35 LocalTime = time.FixedZone("time-local", localOffset)
36 )
37