Get Updates By E-mail 

Article Written By:
Johann Dowa

Timepiece – Swift Library That Dramatically Simplifies Working With Dates

  •  
  •  
  •  
  •  
  •  

Timepiece is an open source Swift library from Naoto Kaneko for working with dates with clean and intuitive syntax that works with iOS, macOS, tvOS and watchOS.

In addition to simple date creation Timepiece supports date calculations, formatting, and parsing of dates.

These code snippets from the readme show the syntax of using Timepiece:

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()

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

1.year.later
1.year.ago

now.string(inDateStyle: .long, andTimeStyle: .medium)
now.dateString(in: .medium)
now.timeString(in: .short)

3.days.string(in: .full)

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

You can find Timepiece on Github here.

A nice Swift library for working with dates.


  •  
  •  
  •  
  •  
  •  

Submit A Resource

Have you created a useful tutorial, library or tool for iOS development that you would like to get in front of our 300,000+ monthly page views from iOS developers?

You can submit the url here.

The resources we feel will appeal to our readers the most will be posted on the front page.

Comments