Contents

Roo

The DateTime data type

Roo provides a convenient data type for working with dates and times, the DateTime object. To create a new instance, use the built-in DateTime() constructor:

var now = DateTime() # This moment in time.
var xmas_2017 = DateTime(1514194200) # From Unix time.
var ymd = DateTime(2018, 01, 31) # From year/month/date.
var bttf = DateTime(1955, 11, 5, 8, 0, 0) # From year/month/date/hour/min/sec

DateTime objects can be manipulated through several method calls:

var now = DateTime() # Current date and time.
var tomorrow = now.add_days(1)

There are also many getters providing information on the object:

var xmas_2017 = DateTime(1514194200)
xmas_2017.today? # => False
xmas_2017.monday? # => True

Comprehensive documentation of the DateTime object’s getters and setters can be found in the DateTime section.