Skip to content

Commit 1348b70

Browse files
committed
Add convenience init for NaiveDateTime
1 parent b4cb93c commit 1348b70

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Sources/NaiveDate.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ public struct NaiveDateTime: Equatable, Hashable, Comparable, LosslessStringConv
154154
self.date = date; self.time = time
155155
}
156156

157+
/// Initializes the naive datetime with a given date components.
158+
/// - important: The naive types don't validate input components. For any
159+
/// precise manipulations with time use native `Date` and `Calendar` types.
160+
public init(year: Int, month: Int, day: Int, hour: Int = 0, minute: Int = 0, second: Int = 0) {
161+
self.date = NaiveDate(year: year, month: month, day: day)
162+
self.time = NaiveTime(hour: hour, minute: minute, second: second)
163+
}
164+
157165
// MARK: Equatable, Hashable, Comparable
158166

159167
public var hashValue: Int {

0 commit comments

Comments
 (0)