Date

Working with Dates and Times

Dates in MaSH allow you to work with dates and times in an object-oriented way.

Under the hood MaSH uses the Carbon package from Brian Nesbitt. You can read more about the package here.


Creating Dates

To create a date in MaSH call the date method on the mash object. Its value will be set to the instance at which it was created.

date

mash.date(string: ?data, string: ?timezone) -> Date

Creates a Date object.

Parameters

data (optional)

A string which can be parsed into a date and time.

timezone (optional)

A valid timezone from the tz database.

Notes

The underlying libraries will attempt to parse any string that you pass to the constructor into a valid date. Examples are 05/23/1982, tommorow and first day of January 2008.

Natural

set date to mash.date()

printline date

Standard

date = mash.date()

printline(date)

Output

Date "2022-02-17T20:29:00.927155Z"

← All articles