You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you create a Date from DateComponents via Calendar and the DateComponents' nanosecond property is equal to or more than a full second, you'll get a SIGTRAP crash.
Example:
letyear=2023letmonth=8letday=27lethour=19letminute=30letsecond=48letnanosecond=Int(1.2*1_000_000_000) // change 1.2 to anything below 1.0 and it won't crash
varcalendar=Calendar(identifier:.gregorian)
calendar.timeZone =TimeZone(secondsFromGMT:0)!
letcomponents=DateComponents(
calendar: calendar,
year: year,
month: month,
day: day,
hour: hour,
minute: minute,
second: second,
nanosecond: nanosecond
)letvalue= calendar.date(from: components)
If you create a
Date
fromDateComponents
viaCalendar
and theDateComponents
'nanosecond
property is equal to or more than a full second, you'll get aSIGTRAP
crash.Example:
Stack trace:
The same code works fine on macOS. Related Swift Forums post: https://forums.swift.org/t/crash-on-linux-when-creating-a-date-from-calendar-date-from-datecomponents/66988
The text was updated successfully, but these errors were encountered: