Swiftpack.co - konomae/swift-local-date as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by konomae.
konomae/swift-local-date 0.4.0
LocalDate for Swift
⭐️ 3
🕓 32 weeks ago
.package(url: "https://github.com/konomae/swift-local-date.git", from: "0.4.0")

LocalDate for Swift

Swift codecov

LocalDate is a struct that represents a date without a time zone, such as a birthday. This library provides the ability to convert a LocalDate to a Date or String and vice versa.

(This is similar to java.time.LocalDate, but this is not intended to be compatible with it. 🙏)


Add the following line to the dependencies in your Package.swift file.

.package(url: "https://github.com/konomae/swift-local-date", from: "0.2.0"),


import LocalDate

let localDate = try LocalDate(from: "1970-01-01")
print(localDate.year) // 1970
print(localDate.month) // 1
print(localDate.day) // 1
print(localDate.description) // 1970-01-01

var date: Date = localDate.date(in: TimeZone(secondsFromGMT: 0)!)
print(date) // 1970-01-01 00:00:00 +0000

date = localDate.date(in: TimeZone(identifier: "Asia/Tokyo")!)
print(date) // 1969-12-31 15:00:00 +0000 (1970-01-01 00:00:00 +0900)


Stars: 3
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics