Day 1.1.4

Day 1.1.4

Maintained by Oleksandr Kirichenko.



Day 1.1.4

  • By
  • Oleksandr Kirichenko

Day

Platform CocoaPods Build Status

Day is the mini library to represent a Day value with serialization functionality. Mainly for private use.

Features

  • Can be created from the Date with resetting of its time components
  • Serialization to the human-readable and sortable String and back
  • Caching (for internal usage)
  • Day seeking algorithms (primarily for my personal need)
  • Convenient property for accessing next and previous day
  • Day offset calculations

Usage

Initialising:

let day = Day() //Day value for the current day
let day = Day(date) //Day value from the date by dropping time components

Serialization:

let serializedString = day.serializedDayString //A serialized string value
let day = Day(serializedString) //Day value from the serialized string

Getting a Date value from the Day value:

let date = day.rawValue

Day calculations:

let nextDay = day.nextDay
let previousDay = day.prevDay
let twoDaysBefore = day.dayBy(addingDays: -2)

Difference between two days:

let diff = day.numberOfDays(sinceDay: day1)
let diff = day.numberOfDays(toDate: day1)