Ruby Dates Cheat Sheet | ShortcutFoo

Ask questions Research chat →

https://www.shortcutfoo.com/app/dojos/ruby-dates/cheatsheet · scraped

ruby

Attachments

Scraped Content

— 481 words · 2026-02-14 17:38:34 UTC ·

Excerpt

Date & Time Parts I d.cwday Return the day of calendar week of date d (1-7, Monday is 1) d.cweek Return the calendar week number of date d (1-53) d.day Return the day of the month of date d (1-31) d.month Return the month (1-12) of date d (option 2) d.wday Return the day of week of date d (0-6, Sunday is zero) d.yday Return the day of year of date d (1-366) d.year Return the year of date d Addition / Subtraction I d + integer Return a date object with integer days added to date d d - integer Return a date object with integer days subtracted from date d d1 - d2 Return the difference between date d1 and date d2 d << integer Return a date object with integer months subtracted from date d d >> integer Return a date object with integer months added to date d d.next Return a date object denoting the following date of date d (option 1) Addition / Subtraction II d.next_day Date d + 1 day (long form) d.next_month Date d + 1 month (long form) d.next_year Date d + 1 year (long form) d.prev_day
Date & Time Parts I d.cwday Return the day of calendar week of date d (1-7, Monday is 1) d.cweek Return the calendar week number of date d (1-53) d.day Return the day of the month of date d (1-31) d.month Return the month (1-12) of date d (option 2) d.wday Return the day of week of date d (0-6, Sunday is zero) d.yday Return the day of year of date d (1-366) d.year Return the year of date d Addition / Subtraction I d + integer Return a date object with integer days added to date d d - integer Return a date object with integer days subtracted from date d d1 - d2 Return the difference between date d1 and date d2 d << integer Return a date object with integer months subtracted from date d d >> integer Return a date object with integer months added to date d d.next Return a date object denoting the following date of date d (option 1) Addition / Subtraction II d.next_day Date d + 1 day (long form) d.next_month Date d + 1 month (long form) d.next_year Date d + 1 year (long form) d.prev_day Date d - 1 day (long form) d.prev_month Date d - 1 month (long form) d.prev_year Date d - 1 year (long form) d.succ Return a date object denoting the following date of date d (option 2) Constants I Date::ABBR_DAYNAMES Array of abbreviated day names Date::ABBR_MONTHNAMES Array of abbreviated month names Date::DAYNAMES Array of full names of days of the week Date::ENGLAND The Julian day number of the day of calendar reform for England and her colonies Date::GREGORIAN The Julian day number of the day of calendar reform for the proleptic Gregorian calendar Date::ITALY The Julian day number of the day of calendar reform for Italy Date::JULIAN The Julian day number of the day of calendar reform for the proleptic Julian calendar Date::MONTHNAMES Array of full month names Conversion I d.to_date Return self of date d d.to_datetime Convert date d to DateTime d.to_s Return a string of date d in ISO 8601 format d.to_time Convert date d to Time Iteration I d1.downto(d2) Iterate down from dates d1 to d2 one day at a time passing date to block d1.step(d2, integer) Iterate integer steps at a time from dates d1 to d2 d1.upto(d2) Iterate up from dates d1 to d2 one day at a time passing date to block Date & Time Parts II d.ajd Return the astronomical Julian day number of date d d.amjd Return the astronomical modified Julian day number of date d d.cwyear Return the calendar week based year of date d d.day_fraction Return the fractional part of the day of date d d.jd Return the Julian day number of date d d.mon Return the month (1-12) of date d (option 1) d.start Return the Julian day number denoting the day of calendar reform

Visibility

Visible to everyone

Reading Status

Related Bookmarks

My Note


Saved!

Annotations

Export as Markdown
+ Annotate selection

Add Annotation