melvitax / DateHelper

A Swift Date extension helper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature Request: Allow checking the RelativeTimeStringType of a Date

emma-k-alexandra opened this issue · comments

Currently toStringWithRelativeTime uses RelativeTimeStringType to output Strings. However, there is no way to determine which RelativeTimeStringType a Date falls into without looking at the output string of toStringWithRelativeTime.

It would be nice to be able to get the RelativeTimeStringType of a Date directly with something like

Date().toRelativeTime() // .nowPast

or

Date().is(.nowPast) // true

This could allow for additional logic switching off of the RelativeTimeStringType of a Date, rather than just converting to a String.

Currently working on a PR if interested

Note that this PR slightly reduces the performance of toStringWithRelativeTime due to duplicating operations with toRelativeTime

Thanks