more core docs
[io.git] / libs / iovm / io / Date.io
blobf79b57744bb4a15df6f20f78387c7a45bc5b323a
1 Date do(
2 docSlot("today", "Set the receiver to the current date, no time information
3 is included. See `now' for the current date and time.")
4 today := method(Date now setHour(0) setMinute(0) setSecond(0))
6 docSlot("isToday", "Returns true if the receiver's date is today's date.")
7 isToday := method(
8 now := Date clone now
9 now year == year and now month == month and now day == day
12 docSlot("secondsToRun(expression)", "Evaluates message and returns a Number
13 whose value is the number of seconds taken to do the evaluation")
14 secondsToRun := method(
15 t1 := Date clone now
16 call relayStopStatus(call evalArgAt(0))
17 dt := Date clone now secondsSince(t1)
20 docSlot("asAtomDate", "Returns the date formatted as a valid atom date (rfc4287) in the system's timezone.")
21 Date asAtomDate := method(
22 asString("%Y-%m-%dT%H:%M:%S") .. gmtOffset asMutable atInsertSeq(3, ":")
24 justSerialized := method(stream,
25 stream write("Date clone do(",
26 "setYear(", self year, ") ",
27 "setMonth(", self month, ") ",
28 "setDay(", self day, ") ",
29 "setHour(", self hour, ") ",
30 "setMinute(", self minute, ") ",
31 "setSecond(", self second, ")",
32 ");")
36 Number do(
37 docSlot("years", "Returns Duration of receiver's years.
39 Example:
40 <pre>
41 Io> 1 years
42 ==> 1 years 00 days 00:00:0.000000
43 Io> 20 years
44 ==> 20 years 00 days 00:00:0.000000
45 </pre>
47 With this, you can do things such as:
48 <pre>
49 Io> Date clone now + 5 years
50 ==> 2011-11-14 18:44:33 EST
51 Io> Date clone now + 2 years + 3 days + 22 minutes
52 ==> 2008-11-17 19:06:54 EST
53 </pre>
55 years := method(Duration clone setYears(self))
57 docSlot("days", "Returns Duration of receiver's days. See `years' for a
58 few examples.")
59 days := method(Duration clone setDays(self))
61 docSlot("hours", "Returns Duration of receiver's hours. See `years' for a
62 few examples.")
63 hours := method(Duration clone setHours(self))
65 docSlot("minutes", "Returns Duration of receiver's minutes. See `years' for
66 a few examples.")
67 minutes := method(Duration clone setMinutes(self))
69 docSlot("seconds", "Returns Duration of receiver's seconds. See `years' for
70 a few examples.")
71 seconds := method(Duration clone setSeconds(self))
74 Duration do(
75 docSlot("+", "Returns a new Duration of the two added.")
76 setSlot("+", method(d, self clone += d))
78 docSlot("-", "Returns a new Duration of the two subtracted.")
79 setSlot("-", method(d, self clone -= d))