explaingit

matthewyork/datetools

7,192Objective-CAudience · developerComplexity · 2/5LicenseSetup · easy

TLDR

An iOS library that makes date and time handling easy in Objective-C and Swift, add human-readable 'time ago' strings in 35+ languages, natural-language date arithmetic, and time period overlap checks.

Mindmap

mindmap
  root((DateTools))
    What it does
      Date arithmetic
      Time ago strings
      Time Period model
    Key features
      35 plus languages
      Natural English syntax
      Period overlap checks
    Tech stack
      Objective-C
      Swift
      CocoaPods
    Use cases
      Timestamp display
      Schedule modeling
      Calendar features
    Audience
      iOS developers
      Mobile app builders
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Display 'posted 2 days ago' or '2d' next to content timestamps in your iOS app, with built-in translations in over 35 languages.

USE CASE 2

Write date arithmetic in plain English, 2.days.earlier or 3.weeks.fromNow, instead of verbose NSCalendar calls.

USE CASE 3

Model schedules or calendar features using Time Periods and check whether events overlap, contain each other, or are chained sequentially.

USE CASE 4

Check if two dates fall on the same day, same week, or within a custom time interval using simple comparison methods.

Tech stack

Objective-CSwiftCocoaPodsiOS

Getting it running

Difficulty · easy Time to first run · 30min

Installation is via CocoaPods, Swift Package Manager support is not mentioned in the documentation.

Use freely for any purpose, including commercially, as long as you keep the MIT copyright notice.

In plain English

DateTools is an iOS library that makes working with dates and times much easier in Objective-C and Swift. Apple's built-in date handling requires a lot of setup code to do common tasks: getting the year or month out of a date, comparing two dates, or calculating how long ago something happened. DateTools reduces that boilerplate to short, readable calls. The library adds several categories of functionality. "Time Ago" strings convert a past date into a phrase like "2 days ago" or a short form like "2d", with translations available in over 35 languages including Arabic, Japanese, Hindi, and Welsh. Date components like year, month, and day become simple properties on a date object. Date arithmetic is written in natural English: 2.days.earlier gives you a date two days before now. Date comparison methods let you check whether two dates are on the same day, in the same week, or within a certain time interval of each other. The more distinctive feature is the Time Period concept. A Time Period is a span of time with a defined start and end. You can check relationships between two periods: whether one contains the other, whether they overlap, and by how much. Time Periods can be grouped into Collections (an unordered set) or Chains (sequential, where each period starts as the previous one ends), which makes reasoning about schedules and event sequences easier. Installation is through CocoaPods, the standard iOS dependency manager. Both Objective-C and Swift versions are available. The README notes that DateTools has been used in well-known apps including YouTube Music and Khan Academy. It is distributed under the MIT license.

Copy-paste prompts

Prompt 1
Using DateTools in Swift, show me how to display a comment's timestamp as 'posted 3 hours ago' and refresh it every minute in a UILabel.
Prompt 2
Write Swift code using DateTools to build a weekly schedule where each day is a chained Time Period, then check if a given event date overlaps with Tuesday.
Prompt 3
Install DateTools via CocoaPods in my Objective-C project and show me how to check whether two NSDate objects fall on the same calendar day.
Prompt 4
Using DateTools, calculate a countdown showing days, hours, and minutes remaining until a future event date and display it in a label.
Prompt 5
I need localized 'time ago' strings in Arabic and Japanese in my iOS app. Show me how DateTools handles these locales including RTL for Arabic.
Open on GitHub → Explain another repo

← matthewyork on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.