Class: Time
Overview
Time — the date helpers. Every method delegates to
Snails::DateAndTime::Calculations, which owns the civil-calendar
arithmetic: day shifts walk the calendar (DST cannot move the clock),
month steps clamp to the target month's last day, and rendering keeps the
receiver's zone (the process zone, UTC, or a fixed offset).
The reopen makes Time-typed parameter slots strict program-wide: a known-type non-Time argument is a build refusal, an unknown-type one a boundary TypeError before the body runs — so no method needs an in-body guard.
Zone conversion lives in Snails::TimeZone, not here.
Instance Method Summary collapse
-
#beginning_of_day ⇒ Time
midnight in the receiver's zone; a UTC receiver stays UTC and a fixed-offset receiver keeps that offset.
-
#beginning_of_hour ⇒ Time
minutes and below zeroed.
-
#beginning_of_minute ⇒ Time
seconds and sub-seconds zeroed.
-
#beginning_of_month ⇒ Time
the 1st at midnight.
-
#beginning_of_week ⇒ Time
Monday, not Sunday (the calendar's week start).
-
#beginning_of_year ⇒ Time
January 1st at midnight.
-
#days_ago(n = 1) ⇒ Time
ncivil days earlier at the same clock time. -
#days_since(n = 1) ⇒ Time
ncivil days later at the same clock time. -
#end_of_day ⇒ Time
23:59:59.999999999, the inclusive end.
-
#end_of_hour ⇒ Time
59:59.999999999, the inclusive end.
-
#end_of_minute ⇒ Time
59.999999999 seconds, the inclusive end.
-
#end_of_month ⇒ Time
the last day's inclusive end (leap years included).
-
#end_of_week ⇒ Time
the following Sunday's inclusive end.
-
#end_of_year ⇒ Time
December 31st's inclusive end.
-
#future? ⇒ Boolean
after now.
-
#in_time_zone(zone) ⇒ Time
the same instant rendered in
zone(a name from the runtime's zone vocabulary,Snails::TimeZone::ZONE_NAMES, or an IANA identifier); nil renders in the current zone. -
#months_ago(n = 1) ⇒ Time
the calendar-month step back.
-
#months_since(n = 1) ⇒ Time
ncalendar months forward, clamped to the target month's last day (Jan 31 + 1 month is Feb 28). -
#next_week ⇒ Time
the next week's Monday, not the receiver plus 7 days.
-
#noon ⇒ Time
12:00:00 of the receiver's day.
-
#on_wday?(wday) ⇒ Boolean
the weekday number matches (0 = Sunday).
-
#on_weekday? ⇒ Boolean
the negation of
on_weekend?. -
#on_weekend? ⇒ Boolean
Saturday or Sunday.
-
#past? ⇒ Boolean
before now.
-
#prev_week ⇒ Time
the previous week's Monday.
-
#same_day?(other) ⇒ Boolean
both fall on the same civil day, clock time irrelevant.
-
#to_fs(name) ⇒ String
:dbis the stored datetime column form (UTC, microsecond precision),:iso8601the JSON spelling: millisecond truncation and the zone's offset. -
#today? ⇒ Boolean
same civil day as now.
-
#tomorrow ⇒ Time
one civil day forward.
-
#tomorrow? ⇒ Boolean
same civil day as one day forward from now.
-
#weeks_ago(n = 1) ⇒ Time
nseven-day steps back. -
#weeks_since(n = 1) ⇒ Time
nseven-day steps forward. -
#years_ago(n = 1) ⇒ Time
the calendar-year step back.
-
#years_since(n = 1) ⇒ Time
ncalendar years forward, clamped like a month step (Feb 29 in a leap year lands on Feb 28). -
#yesterday ⇒ Time
one civil day back.
-
#yesterday? ⇒ Boolean
same civil day as one day back from now.
Instance Method Details
#beginning_of_day ⇒ Time
midnight in the receiver's zone; a UTC receiver stays UTC and a fixed-offset receiver keeps that offset.
48 |
# File 'runtime/ext/time.rb', line 48
def beginning_of_day: () -> Time
|
#beginning_of_hour ⇒ Time
minutes and below zeroed.
33 |
# File 'runtime/ext/time.rb', line 33
def beginning_of_hour: () -> Time
|
#beginning_of_minute ⇒ Time
seconds and sub-seconds zeroed.
19 |
# File 'runtime/ext/time.rb', line 19
def beginning_of_minute: () -> Time
|
#beginning_of_month ⇒ Time
the 1st at midnight.
97 |
# File 'runtime/ext/time.rb', line 97
def beginning_of_month: () -> Time
|
#beginning_of_week ⇒ Time
Monday, not Sunday (the calendar's week start).
69 |
# File 'runtime/ext/time.rb', line 69
def beginning_of_week: () -> Time
|
#beginning_of_year ⇒ Time
January 1st at midnight.
111 |
# File 'runtime/ext/time.rb', line 111
def beginning_of_year: () -> Time
|
#days_ago(n = 1) ⇒ Time
n civil days earlier at the same clock time.
134 |
# File 'runtime/ext/time.rb', line 134
def days_ago: (?Integer n) -> Time
|
#days_since(n = 1) ⇒ Time
n civil days later at the same clock time.
127 |
# File 'runtime/ext/time.rb', line 127
def days_since: (?Integer n) -> Time
|
#end_of_day ⇒ Time
23:59:59.999999999, the inclusive end.
55 |
# File 'runtime/ext/time.rb', line 55
def end_of_day: () -> Time
|
#end_of_hour ⇒ Time
59:59.999999999, the inclusive end.
40 |
# File 'runtime/ext/time.rb', line 40
def end_of_hour: () -> Time
|
#end_of_minute ⇒ Time
59.999999999 seconds, the inclusive end.
26 |
# File 'runtime/ext/time.rb', line 26
def end_of_minute: () -> Time
|
#end_of_month ⇒ Time
the last day's inclusive end (leap years included).
104 |
# File 'runtime/ext/time.rb', line 104
def end_of_month: () -> Time
|
#end_of_week ⇒ Time
the following Sunday's inclusive end.
76 |
# File 'runtime/ext/time.rb', line 76
def end_of_week: () -> Time
|
#end_of_year ⇒ Time
December 31st's inclusive end.
118 |
# File 'runtime/ext/time.rb', line 118
def end_of_year: () -> Time
|
#future? ⇒ Boolean
after now.
236 |
# File 'runtime/ext/time.rb', line 236
def future?: () -> bool
|
#in_time_zone(zone) ⇒ Time
the same instant rendered in zone (a name from the runtime's zone
vocabulary, Snails::TimeZone::ZONE_NAMES, or an IANA identifier); nil
renders in the current zone.
268 |
# File 'runtime/ext/time.rb', line 268
def in_time_zone: (String? zone) -> Time
|
#months_ago(n = 1) ⇒ Time
the calendar-month step back.
177 |
# File 'runtime/ext/time.rb', line 177
def months_ago: (?Integer n) -> Time
|
#months_since(n = 1) ⇒ Time
n calendar months forward, clamped to the target month's last day (Jan 31
- 1 month is Feb 28).
170 |
# File 'runtime/ext/time.rb', line 170
def months_since: (?Integer n) -> Time
|
#next_week ⇒ Time
the next week's Monday, not the receiver plus 7 days.
83 |
# File 'runtime/ext/time.rb', line 83
def next_week: () -> Time
|
#noon ⇒ Time
12:00:00 of the receiver's day.
62 |
# File 'runtime/ext/time.rb', line 62
def noon: () -> Time
|
#on_wday?(wday) ⇒ Boolean
the weekday number matches (0 = Sunday).
257 |
# File 'runtime/ext/time.rb', line 257
def on_wday?: (Integer wday) -> bool
|
#on_weekday? ⇒ Boolean
the negation of on_weekend?.
250 |
# File 'runtime/ext/time.rb', line 250
def on_weekday?: () -> bool
|
#on_weekend? ⇒ Boolean
Saturday or Sunday.
243 |
# File 'runtime/ext/time.rb', line 243
def on_weekend?: () -> bool
|
#past? ⇒ Boolean
before now.
229 |
# File 'runtime/ext/time.rb', line 229
def past?: () -> bool
|
#prev_week ⇒ Time
the previous week's Monday.
90 |
# File 'runtime/ext/time.rb', line 90
def prev_week: () -> Time
|
#same_day?(other) ⇒ Boolean
both fall on the same civil day, clock time irrelevant.
201 |
# File 'runtime/ext/time.rb', line 201
def same_day?: (Time other) -> bool
|
#to_fs(name) ⇒ String
:db is the stored datetime column form (UTC, microsecond precision),
:iso8601 the JSON spelling: millisecond truncation and the zone's offset.
The :db result is lexicographically ordered, so it sorts as text.
280 |
# File 'runtime/ext/time.rb', line 280
def to_fs: (Symbol name) -> String
|
#today? ⇒ Boolean
same civil day as now.
208 |
# File 'runtime/ext/time.rb', line 208
def today?: () -> bool
|
#tomorrow ⇒ Time
one civil day forward.
148 |
# File 'runtime/ext/time.rb', line 148
def tomorrow: () -> Time
|
#tomorrow? ⇒ Boolean
same civil day as one day forward from now.
222 |
# File 'runtime/ext/time.rb', line 222
def tomorrow?: () -> bool
|
#weeks_ago(n = 1) ⇒ Time
n seven-day steps back.
162 |
# File 'runtime/ext/time.rb', line 162
def weeks_ago: (?Integer n) -> Time
|
#weeks_since(n = 1) ⇒ Time
n seven-day steps forward.
155 |
# File 'runtime/ext/time.rb', line 155
def weeks_since: (?Integer n) -> Time
|
#years_ago(n = 1) ⇒ Time
the calendar-year step back.
192 |
# File 'runtime/ext/time.rb', line 192
def years_ago: (?Integer n) -> Time
|
#years_since(n = 1) ⇒ Time
n calendar years forward, clamped like a month step (Feb 29 in a leap year
lands on Feb 28).
185 |
# File 'runtime/ext/time.rb', line 185
def years_since: (?Integer n) -> Time
|
#yesterday ⇒ Time
one civil day back.
141 |
# File 'runtime/ext/time.rb', line 141
def yesterday: () -> Time
|
#yesterday? ⇒ Boolean
same civil day as one day back from now.
215 |
# File 'runtime/ext/time.rb', line 215
def yesterday?: () -> bool
|