Category talk:Wren-date: Difference between revisions
→Source code: Changed Date.fromNum_ from a private to a public constructor.
(→Source code: Improved parsing, added time zone support.) |
(→Source code: Changed Date.fromNum_ from a private to a public constructor.) |
||
Line 469:
}
//
construct
if (num < 0 || num > Date.maximum.number) Fiber.abort("Number is out of range.")
if (!(tz = Date.isValidTz_(tz))) Fiber.abort("Invalid time zone designator.")
Line 483:
static new(y, mo, d) { Date.new(y, mo, d, 0, 0, 0, 0, "UTC") }
static new(y) { Date.new(y, 1, 1, 0, 0, 0, 0, "UTC") }
static fromNumber(num) { Date.fromNumber(num, "UTC") }
// Gets the component parts of this date, as a list, from its number
Line 554 ⟶ 556:
}
addWeeks(w) { Date.
addDays(d) { Date.
addHours(h) { Date.
addMinutes(mi) { Date.
addSeconds(s) { Date.
addMillisecs(ms) { Date.
// Returns the day of the year in which this date falls.
Line 581 ⟶ 583:
// Returns a new date object with the new time zone. Doesn't adjust the time.
changeZone(newZone) { Date.
// Attempts to adjust the time to a new time zone. If successful, returns a
Line 594 ⟶ 596:
var newOffset
if (hasName && !(newOffset = __tzs[newZone])) return null
if (oldOffset == newOffset) return Date.
var ohm = Date.parseOffset_(oldOffset)
var nhm = Date.parseOffset_(newOffset)
var d = Date.
return d.addHours(-ohm[0]).addMinutes(-ohm[1])
}
Line 603 ⟶ 605:
// The inherited 'clone' method just returns 'this' as Date objects are immutable.
// If you need an actual copy use this method instead.
copy() { Date.
// Compares this date with another one to enable comparison operators via Comparable trait.
|