Skip to content

Wrong conversion from toFormat #734

@sameer4

Description

@sameer4

i have a function

func handleDate(for label:UILabel, date: Date?) {
 print("sam |\(date?.convertTo(region: .local).toFormat("HH:mm"))| = #\(date)# = \(Region.local.timeZone.secondsFromGMT() / (60 * 60)) GMT = \(TimeZone.current.secondsFromGMT() / (60 * 60)) GMT")
 label.text = date?.in(region: .local).toFormat("HH:mm") ?? "00:00"
}

from this i got

sam |Optional("09:10")| = #Optional(2001-01-01 08:10:00 +0000)# = 2 GMT = 2 GMT

as you can see i'm in 2 GMT (Copenhagen - Denmark)

so from 2001-01-01 08:10:00 +0000, i should get 10:10 and not 09:10. is there something wrong on my end or is it a bug?

also i have defaults set to

var calender = Calendar.autoupdatingCurrent
calender.firstWeekday = 2
SwiftDate.defaultRegion = Region(calendar: calender, zone: Zones.gmt.toTimezone(), locale: Locales.englishUnitedStatesComputer)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions