Skip to content

Commit 294903c

Browse files
committed
[Date] docs
1 parent 1ac7939 commit 294903c

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

lib/Date.pod

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
=begin pod
2+
3+
=TITLE class Date
4+
5+
class Date { }
6+
7+
A C<Date> is an immutable object identifying a day in the Gregorian calendar.
8+
9+
Date objects support addition and subtraction of integers, where an
10+
integer is interpreted as the number of days. C<Date.today> creates
11+
an object the current day according to the system clock.
12+
13+
=head1 Methods
14+
15+
=head2 new
16+
17+
proto method new() {*}
18+
multi method new($year, $month, $day) returns Date:D
19+
multi method new(:$year, :$month, :$day) returns Date:D
20+
multi method new(Str $date) returns Date:D
21+
multi method new(DateTime:D $dt) returns Date:D
22+
23+
Creates a new C<Date> object, either from a tripple of (year, month, day)
24+
integers, or from a string of the form C<YYYY-MM-DD>
25+
(L<ISO 8601|http://en.wikipedia.org/wiki/ISO_8601>), or from a DateTime
26+
object.
27+
28+
=head2 today
29+
30+
method today() returns Date:D
31+
32+
Returns a C<Date> object for the current day.
33+
34+
my $d = Date.new(2012, 12, 24); # Christmas Eve!
35+
say $d; # 2012-12-24
36+
say $d.year; # 2012
37+
say $d.month; # 12
38+
say $d.day; # 24
39+
say $d.day-of-week; # 1 (that's Monday)
40+
my $n = Date.new('2012-12-31'); # New Year's Eve
41+
say $n - $d; # 7
42+
say $n + 1; # 2013-01-01
43+
44+
=head2 year
45+
46+
method year(Date:D:) returns Int:D
47+
48+
Returns the year of the date
49+
50+
=head2 month
51+
52+
method month(Date:D:) returns Int:D
53+
54+
Returns the month of the date (1..12)
55+
56+
=head2 day
57+
58+
method day(Date:D:) returns Int:D
59+
60+
Returns the day of the month of the date (1..31)
61+
62+
=head2 day-of-week
63+
64+
method day-of-week(Date:D:) returns Int:D
65+
66+
Returns the day of the week, where 0 is Sunday, 1 is Monday etc.
67+
68+
=head2 day-of-year
69+
70+
method day-of-year(Date:D:) returns Int:D
71+
72+
Returns the day of the year.
73+
74+
=head2 day-of-month
75+
76+
method day-of-month(Date:D:) returns Int:D
77+
78+
Returns the day of the month of the date (1..31). Synonymous to the C<day>
79+
method.
80+
81+
=head2 succ
82+
83+
method succ(Date:D:) return Date:D
84+
85+
Returns the following day
86+
87+
=head2 prev
88+
89+
method prev(Date:D:) return Date:D
90+
91+
Returns the previous day
92+
93+
=head2 Str
94+
95+
multi method Str(Date:D:) returns Str:D
96+
97+
Returns the date in C<YYYY-MM-DD> format (L<ISO 8601|http://en.wikipedia.org/wiki/ISO_8601>)
98+
99+
=head2 gist
100+
101+
multi method gist(Date:D:) returns Str:D
102+
103+
Returns the date in C<YYYY-MM-DD> format (L<ISO 8601|http://en.wikipedia.org/wiki/ISO_8601>)
104+
105+
=head2
106+
107+
=end pod

0 commit comments

Comments
 (0)