2013-03-18 06:16



The whole concept of Dates and Times is incredibly flaky and constantly being updated so from the beginning it's an incredibly difficult task. From leap years to leap seconds there are so many variables to take into account.

John Skeet's library looks good but has taken him 3 years to get it this far and it's still far from perfect.

Could someone give me an indication on how the Go programming language handled DateTime's differently or similarly compared to other languages/libraries? This is purely for curiosity's sake.

This question is more about the similarities and differences between current available libraries - preferably in english, not pages and pages of documentation.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongtun1683 dongtun1683 8年前

    See the Go time package documentation and source code. A Time represents an instant in time with nanosecond precision without leap seconds. The IANA Time Zone Database is used for time zone and daylight savings time. The time zone database contains code and data that represent the history of local time for many representative locations around the globe. It is updated periodically to reflect changes made by political bodies to time zone boundaries, UTC offsets, and daylight-saving rules.

    type Time struct {
        // sec gives the number of seconds elapsed since
        // January 1, year 1 00:00:00 UTC.
        sec int64
        // nsec specifies a non-negative nanosecond
        // offset within the second named by Seconds.
        // It must be in the range [0, 999999999].
        nsec int32
        // loc specifies the Location that should be used to
        // determine the minute, hour, month, day, and year
        // that correspond to this Time.
        // Only the zero Time has a nil Location.
        // In that case it is interpreted to mean UTC.
        loc *Location
    点赞 评论 复制链接分享