Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #85 from nodes-vapor/feature/add-seconds-converter
Browse files Browse the repository at this point in the history
Add seconds converter helper
  • Loading branch information
steffendsommer authored Nov 7, 2018
2 parents 33c4f00 + edb1dc9 commit 2a988fb
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions Sources/Sugar/Helpers/SecondsConverter.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// These helpers are not ideal for calculating specific moments in time (past/future).
// See https://nshipster.com/timeinterval-date-dateinterval/ for more information.
// Instead these helpers should be used for e.g. setting a expiration time of something.
public extension Numeric {
public var minsInSecs: Self {
return self * 60
}

public var hoursInSecs: Self {
return self.minsInSecs * 60
}

public var daysInSecs: Self {
return self.hoursInSecs * 24
}

public var weeksInSecs: Self {
return self.daysInSecs * 7
}
}

0 comments on commit 2a988fb

Please sign in to comment.