mirror of
https://github.com/bitwarden/ios.git
synced 2025-12-10 00:42:29 -06:00
[BWA-155] refactor: Pull Date extensions into BitwardenKit (#1459)
This commit is contained in:
parent
a5bd7cf465
commit
3fdefa84df
@ -568,31 +568,4 @@ extension PasswordHistoryView {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension Date {
|
||||
init(
|
||||
year: Int,
|
||||
month: Int,
|
||||
day: Int,
|
||||
hour: Int = 0,
|
||||
minute: Int = 0,
|
||||
second: Int = 0,
|
||||
nanosecond: Int = 0,
|
||||
timeZone: TimeZone = TimeZone(secondsFromGMT: 0)!
|
||||
) {
|
||||
let calendar = Calendar(identifier: .gregorian)
|
||||
let dateComponents = DateComponents(
|
||||
calendar: calendar,
|
||||
timeZone: timeZone,
|
||||
year: year,
|
||||
month: month,
|
||||
day: day,
|
||||
hour: hour,
|
||||
minute: minute,
|
||||
second: second,
|
||||
nanosecond: nanosecond
|
||||
)
|
||||
self = dateComponents.date!
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import Foundation
|
||||
|
||||
extension Date {
|
||||
public extension Date {
|
||||
/// A convenience initializer for `Date` to specify a specific point in time.
|
||||
init(
|
||||
year: Int,
|
||||
month: Int,
|
||||
@ -25,4 +26,15 @@ extension Date {
|
||||
)
|
||||
self = dateComponents.date!
|
||||
}
|
||||
|
||||
// MARK: Methods
|
||||
|
||||
/// Returns a date that is set to midnight on the day that is seven days in the future.
|
||||
///
|
||||
static func midnightOneWeekFromToday() -> Date? {
|
||||
let calendar = Calendar.current
|
||||
guard let date = calendar.date(byAdding: .day, value: 7, to: Date()) else { return nil }
|
||||
guard let date = calendar.date(bySettingHour: 0, minute: 0, second: 0, of: date) else { return nil }
|
||||
return date
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
import Foundation
|
||||
|
||||
extension Date {
|
||||
// MARK: Methods
|
||||
|
||||
/// Returns a date that is set to midnight on the day that is seven days in the future.
|
||||
///
|
||||
static func midnightOneWeekFromToday() -> Date? {
|
||||
let calendar = Calendar.current
|
||||
guard let date = calendar.date(byAdding: .day, value: 7, to: Date()) else { return nil }
|
||||
guard let date = calendar.date(bySettingHour: 0, minute: 0, second: 0, of: date) else { return nil }
|
||||
return date
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
import BitwardenKit
|
||||
import Foundation
|
||||
|
||||
#if DEBUG
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import BitwardenKit
|
||||
import BitwardenSdk
|
||||
import Foundation
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import BitwardenKit
|
||||
@preconcurrency import BitwardenSdk
|
||||
import Foundation
|
||||
|
||||
|
||||
@ -568,31 +568,4 @@ extension PasswordHistoryView {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
extension Date {
|
||||
init(
|
||||
year: Int,
|
||||
month: Int,
|
||||
day: Int,
|
||||
hour: Int = 0,
|
||||
minute: Int = 0,
|
||||
second: Int = 0,
|
||||
nanosecond: Int = 0,
|
||||
timeZone: TimeZone = TimeZone(secondsFromGMT: 0)!
|
||||
) {
|
||||
let calendar = Calendar(identifier: .gregorian)
|
||||
let dateComponents = DateComponents(
|
||||
calendar: calendar,
|
||||
timeZone: timeZone,
|
||||
year: year,
|
||||
month: month,
|
||||
day: day,
|
||||
hour: hour,
|
||||
minute: minute,
|
||||
second: second,
|
||||
nanosecond: nanosecond
|
||||
)
|
||||
self = dateComponents.date!
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user