evening, don't know how convert this:
let birthday = calendar.current.date(era: 1, year: year, month: moth, day: day, hour: 0, minute: 0, second: 0, nanosecond: 0)
into this:
calendar.current.date(from: <datecomponents>)
any tips?
this did:
let datecomponet = datecomponents(timezone: nil, era: 1, year: year, month: month, day: day, hour: 0, minute: 0, second: 0, nanosecond: 0) let birthday = calendar.current.date(from: datecomponet)
is there shorter way?
thanks
yes can pass components want when using initializer:
datecomponents
public init(calendar: calendar? = default, timezone: timezone? = default, era: int? = default, year: int? = default, month: int? = default, day: int? = default, hour: int? = default, minute: int? = default, second: int? = default, nanosecond: int? = default, weekday: int? = default, weekdayordinal: int? = default, quarter: int? = default, weekofmonth: int? = default, weekofyear: int? = default, yearforweekofyear: int? = default)
let birthday = calendar.current.date(from: datecomponents(year: 2016, month: 8, day: 9)) // "aug 9, 2016, 12:00 am"
Comments
Post a Comment