Calendar - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Date and Time : Calendar package : Calendar/AdjustDateField

Calendar

  

AdjustDateField

  

perform calendar arithmetic on individual date fields

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

AdjustDateField( d, field, amount )

Parameters

d

-

Date; a Date object

field

-

string; the date field on which to operate

amount

-

numeric; the amount by which to adjust the indicated field of the date

Description

• 

The AdjustDateField( d ) command operates on individual fields of the Date object d, adjusting (incrementing or decrementing) the indicated field field by the value amount.

• 

There are two methods by which the indicated date field may be adjusted, "add" or "roll".

• 

The "add" method causes an "overflow" of the indicated field to affect successively larger fields of the date.   For example, adding 50 days to the day of the month using the "add" method changes the month field, and possibly the year.

• 

The "roll" method applies the indicated adjustment to the indicated date field without affecting other fields of the date. Instead, the amount value is reduced modulo the valid values of field in the case that these are finite in number. For instance, adding 20 to the day of the week is equivalent to adding 6 to the day of the week, because 20 and 6 are equivalent modulo 7.

• 

The field names that can be adjusted by AdjustDateField are as follows.

"ampm"

the meridian (0=am, 1=pm)

"date"

the day of the month

"day_of_month"

the day of the month (synonym for "date")

"day_of_week"

the day of the week (1..7)

"day_of_year"

the numerical day of the entire year

"era"

the era (0=BCE or 1=CE)

"hour"

the hour of the day

"hour_of_day"

the hour of the day (24-hour clock)

"hour_of_day"

the hour of the day (12-hour clock)

"meridian"

the meridian (0=am, 1=pm) (synonym for "ampm")

"millisecond"

the millisecond within the second

"minute"

the minute of the hour

"month"

the month of the year (1=January, .., 12=December)

"second"

the second of the minute

"week_of_month"

the week within the month (1..5)

"week_of_year"

the week within the year (1..53)

"year"

the year

Examples

withCalendar:

dDate1995,9,23,4,2

d<Date: 1995-09-23T04:02:00 GMT>

(1)

AdjustDateFieldd&comma;day_of_week&comma;3

<Date: 1995-09-20T04:02:00 GMT>

(2)

AdjustDateFieldd&comma;meridian&comma;111

<Date: 1995-11-17T16:02:00 GMT>

(3)

Compatibility

• 

The Calendar[AdjustDateField] command was introduced in Maple 2018.

• 

For more information on Maple 2018 changes, see Updates in Maple 2018.

See Also

Calendar

Date