Contents

dduan/NetTime

RFC 3339 compliant date/time data types.

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

Stars: 8

Forks: 0

Open issues: 2

Default branch: main

Primary language: swift

License: MIT

Topics: date, datetime, rfc-3339, time

README: README.md