Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed wrong timezone while setup a different SwiftDate.defaultRegion #725

Merged
merged 2 commits into from
Sep 15, 2020

Conversation

cythb
Copy link
Contributor

@cythb cythb commented Mar 13, 2020

Get a wrong timezone while setup a diffent SwiftDate.defaultRegion.

    func testUTCZone() {
        SwiftDate.defaultRegion = Region(calendar: Calendars.gregorian, zone: Zones.asiaShanghai, locale: Locales.current)
        
        // DO NOT recognized the right timezone
        // The timezone should be UTC
        let wrongZone = "2020-03-13T05:40:48.000Z"
        let wrongZoneDate = Date.init(wrongZone)
        print(wrongZoneDate!.description) 
        // output: 2020-03-12 21:40:48 +0000
        // I think the correct response is : 2020-03-13 05:40:48 +0000
        XCTAssert("2020-03-13 05:40:48 +0000" == wrongZoneDate!.description)
        
        let iso8601Time = "2020-03-13T05:40:48+00:00"
        let iso8601Date = Date.init(iso8601Time)
        print(iso8601Date!.description) // output: 2020-03-13 05:40:48 +0000
        XCTAssert("2020-03-13 05:40:48 +0000" == iso8601Date!.description)
    }

@cythb
Copy link
Contributor Author

cythb commented Mar 16, 2020

Hi @malcommac, please take a look at this issue.

@malcommac malcommac changed the title get a wrong timezone while setup a diffent SwiftDate.defaultRegion Fixed wrong timezone while setup a different SwiftDate.defaultRegion Sep 15, 2020
@malcommac malcommac added the bug label Sep 15, 2020
@malcommac malcommac added this to the 6.2.0 milestone Sep 15, 2020
@malcommac malcommac merged commit 68266bc into malcommac:develop Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants