You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.5 KiB

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