dduan/nettime
NetTime is a small collection of data types that represent date and time:
Why?
But why not just ues Foundation.Date, you ask?
Turns out, time is hard to represent if you account for different calendars and timezones. But sometimes it's legitimate to ignore this problem. That's why [RFC 3339] exists: "to improve consistency and interoperability when representing and using date and time in Internet protocols." Suffice to say, consistency and interoperability [goes beyond internet protocols][TOML Date].
Further, converting a timestamp to a in-memory object such as TimeInterval or a Foundation.Date a destructive operation: the original time representation is lost. Want to know what timezone offset was used? what the intended precesion for the fraction of seconds was? Tough luck. NetTime preserves all information in an RFC 3339-compliant timestamp.
Installation
With CocoaPods
use_frameworks!
pod "NetTime"With SwiftPM
.package(url: "http://github.com/dduan/NetTime", from: "0.2.3")Caution
Do not use NetTime's data types as direct source for time displayed to end users. Use something like Foundation.DateFormatter and follow best practices. Never assume you know enough about timezones and/or calendars to format date string!
[RFC 3339]: https://tools.ietf.org/html/rfc3339 [TOML Date]: https://toml.io/en/v1.0.0-rc.1#offset-date-time
License
MIT. See LICENSE.md.
Package Metadata
Repository: dduan/nettime
Default branch: main
README: README.md