Module: Snails::DateAndTime::Calculations
- Defined in:
- runtime/snails/date_and_time/calculations.rbs,
runtime/snails/date_and_time/calculations.rb
Class Method Summary collapse
-
.beginning_of_day(t) ⇒ Time
midnight at the start of
t's day. -
.beginning_of_hour(t) ⇒ Time
the start of
t's hour: minutes and smaller fields are zeroed. -
.beginning_of_minute(t) ⇒ Time
the start of
t's minute: seconds and smaller fields are zeroed. -
.beginning_of_month(t) ⇒ Time
the 1st at 00:00 of
t's month. -
.beginning_of_week(t) ⇒ Time
Monday 00:00 of the week containing
t; weeks start on Monday. -
.beginning_of_year(t) ⇒ Time
January 1st at 00:00 of
t's year. -
.civil_days(y, m, d) ⇒ Integer
the civil date as a day count from 1970-01-01, derived from the calendar fields rather than an instant's epoch seconds.
-
.days_ago(t, n = 1) ⇒ Time
ncivil days earlier at the same wall-clock time; the negative twin ofdays_since. -
.days_in_month(y, m) ⇒ Integer
the number of days in the civil month.
-
.days_since(t, n = 1) ⇒ Time
ncivil days later at the same wall-clock time; the day count walks the calendar, so a DST transition cannot move the clock. -
.end_of_day(t) ⇒ Time
the inclusive end of
t's day, on the last nanosecond (23:59:59.999999999). -
.end_of_hour(t) ⇒ Time
the inclusive end of
t's hour, on the last nanosecond (…:59.999999999). -
.end_of_minute(t) ⇒ Time
the inclusive end of
t's minute, on the last nanosecond (…:59.999999999). -
.end_of_month(t) ⇒ Time
the last day of
t's month at its inclusive end (leap years included). -
.end_of_week(t) ⇒ Time
Sunday 23:59:59.999999999 of the week containing
t. -
.end_of_year(t) ⇒ Time
December 31st at its inclusive end of
t's year. -
.future?(t, now) ⇒ Boolean
tis later thannow. -
.months_ago(t, n = 1) ⇒ Time
ncalendar months earlier at the same wall-clock time; the negative twin ofmonths_since. -
.months_since(t, n = 1) ⇒ Time
ncalendar months later at the same wall-clock time; the day clamps to the target month's last day (Jan 31 + 1 month is Feb 29 in a leap year). -
.next_week(t) ⇒ Time
Monday 00:00 of the week after
t's week. -
.noon(t) ⇒ Time
12:00:00 of
t's day. -
.on_wday?(t, wday) ⇒ Boolean
tfalls on the given Sunday-based weekday (0 Sunday … 6 Saturday). -
.on_weekday?(t) ⇒ Boolean
tfalls on Monday through Friday. -
.on_weekend?(t) ⇒ Boolean
tfalls on Saturday or Sunday. -
.past?(t, now) ⇒ Boolean
tis earlier thannow. -
.prev_week(t) ⇒ Time
Monday 00:00 of the week before
t's week. -
.same_day?(a, b) ⇒ Boolean
both instants fall on the same civil date.
-
.today?(t, now) ⇒ Boolean
tfalls onnow's civil date. -
.tomorrow(t) ⇒ Time
one civil day later at the same wall-clock time.
-
.tomorrow?(t, now) ⇒ Boolean
tfalls on the civil date afternow. -
.weeks_ago(t, n = 1) ⇒ Time
nweeks (7 days each) earlier at the same wall-clock time. -
.weeks_since(t, n = 1) ⇒ Time
nweeks (7 days each) later at the same wall-clock time. -
.years_ago(t, n = 1) ⇒ Time
ncalendar years (12 months each) earlier at the same wall-clock time; the negative twin ofyears_since. -
.years_since(t, n = 1) ⇒ Time
ncalendar years (12 months each) later at the same wall-clock time; a leap day clamps to the target month's last day. -
.yesterday(t) ⇒ Time
one civil day earlier at the same wall-clock time.
-
.yesterday?(t, now) ⇒ Boolean
tfalls on the civil date beforenow.
Class Method Details
.beginning_of_day(t) ⇒ Time
midnight at the start of t's day.
219 |
# File 'runtime/snails/date_and_time/calculations.rb', line 219
def self.beginning_of_day: (Time t) -> Time
|
.beginning_of_hour(t) ⇒ Time
the start of t's hour: minutes and smaller fields are zeroed.
196 |
# File 'runtime/snails/date_and_time/calculations.rb', line 196
def self.beginning_of_hour: (Time t) -> Time
|
.beginning_of_minute(t) ⇒ Time
the start of t's minute: seconds and smaller fields are zeroed.
173 |
# File 'runtime/snails/date_and_time/calculations.rb', line 173
def self.beginning_of_minute: (Time t) -> Time
|
.beginning_of_month(t) ⇒ Time
the 1st at 00:00 of t's month.
297 |
# File 'runtime/snails/date_and_time/calculations.rb', line 297
def self.beginning_of_month: (Time t) -> Time
|
.beginning_of_week(t) ⇒ Time
Monday 00:00 of the week containing t; weeks start on Monday.
253 |
# File 'runtime/snails/date_and_time/calculations.rb', line 253
def self.beginning_of_week: (Time t) -> Time
|
.beginning_of_year(t) ⇒ Time
January 1st at 00:00 of t's year.
319 |
# File 'runtime/snails/date_and_time/calculations.rb', line 319
def self.beginning_of_year: (Time t) -> Time
|
.civil_days(y, m, d) ⇒ Integer
the civil date as a day count from 1970-01-01, derived from the calendar fields rather than an instant's epoch seconds.
18 |
# File 'runtime/snails/date_and_time/calculations.rb', line 18
def self.civil_days: (Integer y, Integer m, Integer d) -> Integer
|
.days_ago(t, n = 1) ⇒ Time
n civil days earlier at the same wall-clock time; the negative twin of
days_since.
60 |
# File 'runtime/snails/date_and_time/calculations.rb', line 60
def self.days_ago: (Time t, ?Integer n) -> Time
|
.days_in_month(y, m) ⇒ Integer
the number of days in the civil month.
34 |
# File 'runtime/snails/date_and_time/calculations.rb', line 34
def self.days_in_month: (Integer y, Integer m) -> Integer
|
.days_since(t, n = 1) ⇒ Time
n civil days later at the same wall-clock time; the day count walks
the calendar, so a DST transition cannot move the clock.
47 |
# File 'runtime/snails/date_and_time/calculations.rb', line 47
def self.days_since: (Time t, ?Integer n) -> Time
|
.end_of_day(t) ⇒ Time
the inclusive end of t's day, on the last nanosecond
(23:59:59.999999999).
231 |
# File 'runtime/snails/date_and_time/calculations.rb', line 231
def self.end_of_day: (Time t) -> Time
|
.end_of_hour(t) ⇒ Time
the inclusive end of t's hour, on the last nanosecond
(…:59.999999999).
208 |
# File 'runtime/snails/date_and_time/calculations.rb', line 208
def self.end_of_hour: (Time t) -> Time
|
.end_of_minute(t) ⇒ Time
the inclusive end of t's minute, on the last nanosecond
(…:59.999999999).
185 |
# File 'runtime/snails/date_and_time/calculations.rb', line 185
def self.end_of_minute: (Time t) -> Time
|
.end_of_month(t) ⇒ Time
the last day of t's month at its inclusive end (leap years included).
308 |
# File 'runtime/snails/date_and_time/calculations.rb', line 308
def self.end_of_month: (Time t) -> Time
|
.end_of_week(t) ⇒ Time
Sunday 23:59:59.999999999 of the week containing t.
264 |
# File 'runtime/snails/date_and_time/calculations.rb', line 264
def self.end_of_week: (Time t) -> Time
|
.end_of_year(t) ⇒ Time
December 31st at its inclusive end of t's year.
330 |
# File 'runtime/snails/date_and_time/calculations.rb', line 330
def self.end_of_year: (Time t) -> Time
|
.future?(t, now) ⇒ Boolean
t is later than now.
402 |
# File 'runtime/snails/date_and_time/calculations.rb', line 402
def self.future?: (Time t, Time now) -> bool
|
.months_ago(t, n = 1) ⇒ Time
n calendar months earlier at the same wall-clock time; the negative
twin of months_since.
136 |
# File 'runtime/snails/date_and_time/calculations.rb', line 136
def self.months_ago: (Time t, ?Integer n) -> Time
|
.months_since(t, n = 1) ⇒ Time
n calendar months later at the same wall-clock time; the day clamps to
the target month's last day (Jan 31 + 1 month is Feb 29 in a leap year).
119 |
# File 'runtime/snails/date_and_time/calculations.rb', line 119
def self.months_since: (Time t, ?Integer n) -> Time
|
.next_week(t) ⇒ Time
Monday 00:00 of the week after t's week.
275 |
# File 'runtime/snails/date_and_time/calculations.rb', line 275
def self.next_week: (Time t) -> Time
|
.noon(t) ⇒ Time
12:00:00 of t's day.
242 |
# File 'runtime/snails/date_and_time/calculations.rb', line 242
def self.noon: (Time t) -> Time
|
.on_wday?(t, wday) ⇒ Boolean
t falls on the given Sunday-based weekday (0 Sunday … 6 Saturday).
433 |
# File 'runtime/snails/date_and_time/calculations.rb', line 433
def self.on_wday?: (Time t, Integer wday) -> bool
|
.on_weekday?(t) ⇒ Boolean
t falls on Monday through Friday.
422 |
# File 'runtime/snails/date_and_time/calculations.rb', line 422
def self.on_weekday?: (Time t) -> bool
|
.on_weekend?(t) ⇒ Boolean
t falls on Saturday or Sunday.
412 |
# File 'runtime/snails/date_and_time/calculations.rb', line 412
def self.on_weekend?: (Time t) -> bool
|
.past?(t, now) ⇒ Boolean
t is earlier than now.
390 |
# File 'runtime/snails/date_and_time/calculations.rb', line 390
def self.past?: (Time t, Time now) -> bool
|
.prev_week(t) ⇒ Time
Monday 00:00 of the week before t's week.
286 |
# File 'runtime/snails/date_and_time/calculations.rb', line 286
def self.prev_week: (Time t) -> Time
|
.same_day?(a, b) ⇒ Boolean
both instants fall on the same civil date.
342 |
# File 'runtime/snails/date_and_time/calculations.rb', line 342
def self.same_day?: (Time a, Time b) -> bool
|
.today?(t, now) ⇒ Boolean
t falls on now's civil date.
354 |
# File 'runtime/snails/date_and_time/calculations.rb', line 354
def self.today?: (Time t, Time now) -> bool
|
.tomorrow(t) ⇒ Time
one civil day later at the same wall-clock time.
82 |
# File 'runtime/snails/date_and_time/calculations.rb', line 82
def self.tomorrow: (Time t) -> Time
|
.tomorrow?(t, now) ⇒ Boolean
t falls on the civil date after now.
378 |
# File 'runtime/snails/date_and_time/calculations.rb', line 378
def self.tomorrow?: (Time t, Time now) -> bool
|
.weeks_ago(t, n = 1) ⇒ Time
n weeks (7 days each) earlier at the same wall-clock time.
106 |
# File 'runtime/snails/date_and_time/calculations.rb', line 106
def self.weeks_ago: (Time t, ?Integer n) -> Time
|
.weeks_since(t, n = 1) ⇒ Time
n weeks (7 days each) later at the same wall-clock time.
94 |
# File 'runtime/snails/date_and_time/calculations.rb', line 94
def self.weeks_since: (Time t, ?Integer n) -> Time
|
.years_ago(t, n = 1) ⇒ Time
n calendar years (12 months each) earlier at the same wall-clock time;
the negative twin of years_since.
162 |
# File 'runtime/snails/date_and_time/calculations.rb', line 162
def self.years_ago: (Time t, ?Integer n) -> Time
|
.years_since(t, n = 1) ⇒ Time
n calendar years (12 months each) later at the same wall-clock time; a
leap day clamps to the target month's last day.
149 |
# File 'runtime/snails/date_and_time/calculations.rb', line 149
def self.years_since: (Time t, ?Integer n) -> Time
|
.yesterday(t) ⇒ Time
one civil day earlier at the same wall-clock time.
71 |
# File 'runtime/snails/date_and_time/calculations.rb', line 71
def self.yesterday: (Time t) -> Time
|
.yesterday?(t, now) ⇒ Boolean
t falls on the civil date before now.
366 |
# File 'runtime/snails/date_and_time/calculations.rb', line 366
def self.yesterday?: (Time t, Time now) -> bool
|