diff --git a/Sources/SwiftDate/Date/Date.swift b/Sources/SwiftDate/Date/Date.swift index 9e7b8011..060a8cd1 100644 --- a/Sources/SwiftDate/Date/Date.swift +++ b/Sources/SwiftDate/Date/Date.swift @@ -57,6 +57,11 @@ extension Date: DateRepresentable { public var dateComponents: DateComponents { return region.calendar.dateComponents(DateComponents.allComponentsSet, from: self) } + + /// Get the total number of seconds in the registered 'time'. + public var totalSeconds: Int { + return ((hour * 60) + minute) * 60 + second; + } /// Initialize a new date object from string expressed in given region. /// diff --git a/Sources/SwiftDate/DateInRegion/DateInRegion.swift b/Sources/SwiftDate/DateInRegion/DateInRegion.swift index 98133f70..0d521742 100644 --- a/Sources/SwiftDate/DateInRegion/DateInRegion.swift +++ b/Sources/SwiftDate/DateInRegion/DateInRegion.swift @@ -30,6 +30,9 @@ public struct DateInRegion: DateRepresentable, Decodable, Encodable, CustomStrin public var dateComponents: DateComponents { return region.calendar.dateComponents(DateComponents.allComponentsSet, from: date) } + + /// Get the total number of seconds in the registered 'time'. + public var totalSeconds: Int /// Description of the date public var description: String { diff --git a/Sources/SwiftDate/DateRepresentable.swift b/Sources/SwiftDate/DateRepresentable.swift index 717fd21f..50c48457 100644 --- a/Sources/SwiftDate/DateRepresentable.swift +++ b/Sources/SwiftDate/DateRepresentable.swift @@ -52,6 +52,9 @@ public protocol DateRepresentable { /// Second unit of the receiver. var second: Int { get } + + /// Total seconds of the receiver. + var totalSeconds: Int { get } /// Nanosecond unit of the receiver. var nanosecond: Int { get } diff --git a/Sources/SwiftDate/Formatters/RelativeFormatter/langs/en.json b/Sources/SwiftDate/Formatters/RelativeFormatter/langs/en.json index 223f7020..aa9c236f 100644 --- a/Sources/SwiftDate/Formatters/RelativeFormatter/langs/en.json +++ b/Sources/SwiftDate/Formatters/RelativeFormatter/langs/en.json @@ -230,4 +230,4 @@ "current" : "this qtr." } } -} \ No newline at end of file +}