Timepiece

Intuitive date handling in Swift

  • Owner: naoty/Timepiece
  • Platform:
  • License:: MIT License
  • Category::
  • Topic:
  • Like:
    0
      Compare:

Github stars Tracking Chart

Timepiece CocoaPods Compatible Build Status

Intuitive date handling in Swift

Features

  • :bulb: Intuitive: Timepiece provides a set of helpers to make date handling easier.
  • :clock9: Correct: Using Foundation API correctly, Timepiece helps to calculate dates correctly without deep understanding.
  • :package: Small: Timepiece has only 4 file. You can read the inside of this easily.

Requirements

  • Swift 3.0+
  • iOS 8.0+ / macOS 10.9+ / tvOS 9.0+ / watchOS 2.0+

Usage

Initialization

Date(era: 235, year: 26, month: 8, day: 14, hour: 20, minute: 25, second: 43, nanosecond: 0, on: Calendar(identifier: .japanese))
Date(year: 2014, month: 8, day: 14, hour: 20, minute: 25, second: 43, nanosecond: 0)
Date(year: 2014, month: 8, day: 14, hour: 20, minute: 25, second: 43)
Date(year: 2014, month: 8, day: 14)

Date.today()
Date.yesterday()
Date.tomorrow()

Calculation

now + 1.year
now - 2.months
now + (3.weeks - 4.days + 5.hours)

1.year.later
1.year.ago

Change

now.changed(year: 2014)
now.changed(weekday: 1)
now.truncated([.minute, .second, .nanosecond])
now.truncated(from: .day)

Formating

now.stringIn(dateStyle: .long, timeStyle: .medium)
now.dateString(in: .medium)
now.timeString(in: .short)

3.days.string(in: .full)

Parsing

"2014/8/14".date(inFormat: "yyyy/MM/dd")
"2014-08-14T20:25:43+0900".dateInISO8601Format()

Installation

CocoaPods

# Podfile
pod "Timepiece"

Carthage

# Cartfile
github "naoty/Timepiece"

Contribution

  1. Fork
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

Timepiece is available under the MIT license. See the LICENSE file for more info.

Author

naoty

Overview

Name With Ownernaoty/Timepiece
Primary LanguageSwift
Program languageSwift (Language Count: 2)
Platform
License:MIT License
Release Count22
Last Release Name1.3.1 (Posted on )
First Release Name0.1.0 (Posted on )
Created At2014-08-16 10:35:34
Pushed At2019-10-15 08:55:28
Last Commit At2019-05-07 13:16:23
Stargazers Count2.6k
Watchers Count42
Fork Count148
Commits Count201
Has Issues Enabled
Issues Count52
Issue Open Count7
Pull Requests Count33
Pull Requests Open Count1
Pull Requests Close Count19
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private
To the top