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
⭐️ 4
🕓 1 year 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. 🙏)

Installation

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

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

Example

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)

GitHub

link
Stars: 4
Last commit: 4 days ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

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