Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Sources/SwiftDate/Date/Date.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
3 changes: 3 additions & 0 deletions Sources/SwiftDate/DateInRegion/DateInRegion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions Sources/SwiftDate/DateRepresentable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,4 @@
"current" : "this qtr."
}
}
}
}