Popularity
0.4
Growing
Activity
0.0
Stable
5
4
0

Description

Calendar dates for Swift, built around DateComponents. Provides value objects for representing dates and times that are not directly bound to specific UTC offsets or timezones. This is useful when working with future events, as in the case of event and appointment scheduling apps.

Programming language: Swift
License: MIT License
Tags: Date     Calendar     Swift     Time    

CalendarDate alternatives and similar libraries

Based on the "Date" category.
Alternatively, view CalendarDate alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of CalendarDate or a related project?

Add another 'Date' Library

README

CalendarDate

Calendar dates for Swift, built around DateComponents. Provides value objects for representing dates and times that are not directly bound to specific UTC offsets or timezones. This is useful when working with future events, as in the case of event and appointment scheduling apps.

CalendarDate provides the following value types:

  • CalendarTime: Represents a wall time, such as "2:00PM".
  • CalendarDate: Represents a calendar date, such as a birthday.
  • CalendarDateTime: Groups CalendarDate and CalendarTime to represent a date + time.

How to use it

You can initialize a CalendarDateTime value directly and convert it to a Swift Date when you need to display it to the user.

let meetingDate = CalendarDateTime(year: 2020, month: 4, day: 1, hour: 10, minute: 30)
let meetingTimezone = TimeZone(identifier: "America/New_York")

let date = meetingDate.asDate(timezone: meetingTimezone!)

let formatter = DateFormatter()
formatter.dateStyle = .long
formatter.timeStyle = .long
formatter.timeZone = TimeZone(identifier: "America/New_York") // Or .current

formatter.string(from: date) // -> "April 1, 2020 at 10:30:00 AM EDT"

Codable

The value types provided by this library all conform to Codable.

Value Type Codable format
CalendarTime hh:mm:ss
CalendarDate YYYY-MM-DD
CalendarDateTime YYYY-MM-DDThh:mm:ss

Recommended reads