module VirtualTime::TimeHelper

Defined in:

virtualtime.cr

Class Method Summary

Class Method Detail

def self.day_of_week(time : Time) #

Returns day of week of specified time


[View source]
def self.day_of_week(time : VirtualTime) #

Returns day of week of specified time


[View source]
def self.day_of_year(time) #

Returns day of year of specified time


[View source]
def self.days_in_month(time : Time) #

Returns number of days in month of specified time


[View source]
def self.days_in_month(time : VirtualTime) #

Returns number of days in month of specified time


[View source]
def self.days_in_year(time : Time) #

Returns number of days in current year


[View source]
def self.days_in_year(time : VirtualTime) #

Returns number of days in current year. For a VT this is always 0 since value is not determinable


[View source]
def self.week(time : Time) #

Returns week number (0..53) of specified time


[View source]
def self.week(time : VirtualTime) #

Returns week number (0..53) of specified time


[View source]
def self.week_of_year(time) #

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.


[View source]
def self.weeks_in_year(time : Time) #

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.


[View source]