Skip to content

Commit 3b7440d

Browse files
author
Jan-Olof Hendig
committed
Added documentation for method week-number and wrote some code examples for is-leap-year and days-in-month
1 parent 26bd494 commit 3b7440d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

doc/Type/Dateish.pod

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ Usage:
7979
Returns C<True> if C<$year> is a leap year. Can be called as a class method
8080
if the year is provided.
8181
82+
say Dateish.is-leap-year(2016); # True
83+
say Date.new("1900-01-01").is-leap-year; # False
84+
8285
=head2 method day-of-month
8386
8487
Defined as:
@@ -130,6 +133,9 @@ Returns the number of days in a month, where year and month default to that
130133
of the invocant. If both year and month are provided, it can be called as
131134
a class method.
132135
136+
say Date.new("2016-01-02").days-in-month; # 31
137+
say Dateish.days-in-month(2016, 1); # 31
138+
133139
=head2 method week
134140
135141
Defined as:
@@ -148,6 +154,25 @@ at the start or end of a year, the week may actually belong to the other year.
148154
say $week; # 1
149155
say Date.new('2015-01-31').week; # 2015 5
150156
157+
=head2 method week-number
158+
159+
Defined as:
160+
161+
method week-number(Date:D:) returns Int:D
162+
163+
Usage:
164+
165+
Dateish.week-number
166+
167+
Returns the week number (1..53) of the date specified by the invocant. The first
168+
week of the year is defined by ISO as the one which contains the fourth day of
169+
January. Thus, dates early in January often end up in the last week of the prior
170+
year, and similarly, the final few days of December may be placed in the first
171+
week of the next year.
172+
173+
say Date.new("2014-12-31").week-number; # 1 (first week of 2015)
174+
say Date.new("2016-01-02").week-number; # 53 (last week of 2015)
175+
151176
=head2 method weekday-of-month
152177
153178
Defined as:

0 commit comments

Comments
 (0)