Package: Kernel-Dates
Class: Date
Introduction
Environment: container
A Date is an object which holds a specific point in time, from year to seconds.
Currently, there are hard-coded strings for days of the week (Monday - Sunday) as well as months in a year (January - December), and also their abbreviations.
Both days of week and months in year are indexed starting with 1 (Monday and January).
Most of the available functions use the Date class instead of a Date instance.
For example:
dv := Date daysInYear: 2024. "dv = 366"
dv := Date daysInMonth: 'February' forYear: 2020. "dv = 29"
dv := Date daysInMonth: 'October' forYear: 2022. "dv = 31"
ds := ':'.
dv := { 3. 6. 9 } do: [ :each | ds := ds + (Date shortNameOfMonth: each) + ':' ].
ds = ':Mar:Jun:Sep:'. "true"Class Method
Category: accessing
abbreviationOfDay:- Answer the abbreviated name of the day of week corresponding to the given index (1=Mon, 7=Sun based).For example:
dayOfWeek:- Answer the index of the day of week corresponding to the given name (1=Monday, 7=Sunday based).For example:
daysInMonth:forYear:- Answer the number of days in the given (named) month for the given year.For example:
daysInYear:- Answer the number of days in the given year.For example:
indexOfMonth:- Answer the index of the month corresponding to the given name (1=January based).For example:
nameOfDay:- Answer the name of the day of week corresponding to the given index (1=Monday, 7=Sunday based).For example:
nameOfMonth:- Answer the name of the month corresponding to the given index (1=January based).For example:
shortNameOfMonth:- Answer the name of the month corresponding to the given index (1=January based).For example:
Category: instance creation
year:day:hour:minute:second:- Answer a Date denoting the d-th day of the given year.For example:
year:month:day:hour:minute:second:- Answer a Date denoting the d-th day of the given (as a number) month and year.For example:
Last updated
Was this helpful?