Skip to content

Commit

Permalink
feature: add implementation for the unix time
Browse files Browse the repository at this point in the history
  • Loading branch information
Bolorunduro Winner-Timothy committed May 11, 2019
1 parent 1a5de08 commit 1f22bc0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/RelativeTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ public static string CalendarTime(this DateTime This, CalendarTimeFormats format
return endDate.ToString(formats.EverythingElse);
}

public static double UnixTimestampInSeconds(this DateTime This)
{
var timeSpan = This - UnixEpoch;
return timeSpan.TotalSeconds;
}

public static double UnixTimestampInMilliseconds(this DateTime This)
{
var timeSpan = This - UnixEpoch;
return timeSpan.TotalMilliseconds;
}

private static string ParseFromPastTimeSpan(TimeSpan timeSpan)
{
return $"{ParseTimeDifference(timeSpan)} ago";
Expand Down

0 comments on commit 1f22bc0

Please sign in to comment.