Skip to content

Commit f750952

Browse files
committed
Add new TimeSpan/DateTime/Guid .parse APIs
1 parent 1079936 commit f750952

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

Sources/ServiceStack/CoreTypes.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ public struct TimeSpan {
152152
public init(wrappedValue: TimeInterval?) {
153153
self.wrappedValue = wrappedValue
154154
}
155+
public static func parse(_ timeSpan:String) -> TimeInterval? {
156+
return TimeInterval.fromString(timeSpan)
157+
}
155158
}
156159

157160
extension TimeSpan : Codable {
@@ -377,3 +380,10 @@ extension TimeInterval {
377380
}
378381
}
379382
}
383+
384+
public class Guid {
385+
public static func parse(_ guid:String) -> String? {
386+
return guid
387+
}
388+
}
389+

Sources/ServiceStack/DateExtensions.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88

99
import Foundation
1010

11+
public class DateTime {
12+
public static func parse(_ dateTime:String) -> Date? {
13+
return Date.fromString(dateTime)
14+
}
15+
}
16+
1117
public extension Date {
1218
init(dateString: String, format: String = "yyyy-MM-dd") {
1319
let fmt = DateFormatter()

0 commit comments

Comments
 (0)