Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issue #717 - Get the total second from mm:ss format #781

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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."
}
}
}
}