Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pantelis Giazitsis committed Jan 16, 2025
1 parent 4da15d2 commit ab2b028
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
5 changes: 3 additions & 2 deletions WeatherXMTests/Toolkit/DateExtensionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ final class DateExtensionsTests: XCTestCase {
date = date?.set(day: 5)
date = date?.set(month: 5)
date = date?.set(year: 2024)
let expectedResult = "2024-05-05T03:00:00\(TimeZone.current.fomattedGMTOffset)"
XCTAssert(date?.toTimestamp() == expectedResult, "Timestamp should be \(expectedResult)")
let expectedResult = "2024-05-05T03:00:00\(TimeZone.current.fomattedGMTOffset(date: date!))"
let result = date?.toTimestamp()
XCTAssert(result == expectedResult, "Timestamp should be \(expectedResult)")
}

func testTransactionsDateFormat() {
Expand Down
4 changes: 2 additions & 2 deletions WeatherXMTests/Toolkit/WEIConverterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ final class WEIConverterTests: XCTestCase {

func testOnlySpacesString() throws {
let converter = WEIConverter(value: " ")
XCTAssertNil(converter.toEthDecimal)
XCTAssertNil(converter.toEthDouble)
XCTAssertEqual(converter.toEthDecimal, 0.0)
XCTAssertEqual(converter.toEthDouble, 0.0)
}

func testNonDigitsString() throws {
Expand Down
12 changes: 7 additions & 5 deletions wxm-ios/Toolkit/Toolkit/Utils/DateExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ public extension Date {

func toTimestamp(with timeZone: TimeZone = .current) -> String {
let dateformat = DateFormatter()
dateformat.timeZone = timeZone
dateformat.dateFormat = DateFormat.timestamp.rawValue
dateformat.locale = Locale(identifier: "en_US_POSIX")
dateformat.timeZone = timeZone
return dateformat.string(from: self)
}

Expand Down Expand Up @@ -324,10 +324,12 @@ public extension TimeZone {
secondsFromGMT() == 0
}

var fomattedGMTOffset: String {
let timeZoneFormatter = DateFormatter()
timeZoneFormatter.dateFormat = "ZZZZZ"
return timeZoneFormatter.string(from: Date())
func fomattedGMTOffset(date: Date = .now) -> String {
let timeZoneFormatter = DateFormatter()
timeZoneFormatter.dateFormat = "ZZZZZ"
timeZoneFormatter.timeZone = self
timeZoneFormatter.locale = Locale(identifier: "en_US_POSIX")
return timeZoneFormatter.string(from: date)
}

static var UTCTimezone: TimeZone? {
Expand Down

0 comments on commit ab2b028

Please sign in to comment.