module VirtualTime::TimeHelper
Defined in:
virtualtime.crClass Method Summary
-
.days_in_month(time)
Returns number of days in current month
-
.days_in_year(time)
Returns number of days in current year
-
.week_of_year(time)
Returns current week of year.
-
.weeks_in_year(time)
Returns number of weeks in a year.
Class Method Detail
Returns current week of year.
This function returns a value in range 0..53.
Up to first 3 days of a year (Jan 1-3) may return value 0. This means they are in the new year, but technically they belong to a week that started on Monday in the previous year. Week number 53 means January 1 is on a Friday, or the year was a leap year.
The calculation is identical as the first part of Time#calendar_week
.
Returns number of weeks in a year. It is calculated as number of Mondays in the year up to the ordinal date.
Thus it is possible for this function to return value of 53
(53th week in a year) for up to 4 last days in the current year.
That is, for Dec 28-31. An example of such year was 2020.
In other words, value 53
will be seen if January 1 of next year is on a Friday, or the year was a leap year.
The calculation is identical as the first part of Time#calendar_week
.
.