Merge branch 'feature/utility_tweaks' into 'develop'
Core utility tweaks ### Summary unixMilleseconds calculation using an existing date object. Open toJSONString options. See merge request https://gitlab.verizon.com/BPHV_MIPS/mvm_core/-/merge_requests/310
This commit is contained in:
commit
1efd261de3
@ -11,6 +11,10 @@ import Foundation
|
||||
public extension Date {
|
||||
|
||||
static func unixMillisecondsNow() -> Int64 {
|
||||
return Int64(Self().timeIntervalSince1970 * 1000)
|
||||
return Self().unixMilliseconds()
|
||||
}
|
||||
|
||||
func unixMilliseconds() -> Int64 {
|
||||
return Int64(self.timeIntervalSince1970 * 1000)
|
||||
}
|
||||
}
|
||||
|
||||
@ -43,9 +43,9 @@ extension Encodable {
|
||||
return jsonArray
|
||||
}
|
||||
|
||||
public func toJSONString() -> String? {
|
||||
public func toJSONString(options: JSONSerialization.WritingOptions = .prettyPrinted) -> String? {
|
||||
guard let json = self.toJSON(),
|
||||
let data = try? JSONSerialization.data(withJSONObject: json, options: .prettyPrinted),
|
||||
let data = try? JSONSerialization.data(withJSONObject: json, options: options),
|
||||
let string = String(data: data, encoding: .utf8) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user