Skip to content

Commit 39d1cd4

Browse files
author
Alessio Arsuffi
committed
fix date tests 3
1 parent 033fead commit 39d1cd4

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Marvin/Date/Date.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ public extension Date {
3232
/// - Parameter format: Date format (ex: "yyyy mm dd")
3333
/// default: yyyy mm dd
3434
/// - Returns: a string from date
35-
public func string(dateFormat format: String? = "yyyy MM dd") -> String {
35+
36+
/// - format: Date format (ex: "yyyy mm dd")
37+
/// default: yyyy mm dd
38+
/// - locale: locale identifier, default "it_IT"
39+
/// - Returns: a string from date
40+
public func string(dateFormat format: String? = "yyyy MM dd", locale: String = "it_IT") -> String {
3641
let dateFormatter = DateFormatter()
42+
dateFormatter.locale = Locale(identifier: locale)
3743
dateFormatter.dateFormat = format
3844
return dateFormatter.string(from: self)
3945
}

MarvinTests/Date/DateTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class DateTests: XCTestCase {
3131
return
3232
}
3333

34-
let calendar = Calendar(identifier: .gregorian)
34+
var calendar = Calendar(identifier: .gregorian)
35+
calendar.locale = Locale(identifier: "it_IT")
3536
let components = calendar.dateComponents([.year, .month, .day], from: date)
3637

3738
let day = components.day

0 commit comments

Comments
 (0)