> ## Documentation Index
> Fetch the complete documentation index at: https://docs.canton.network/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> If you are building a Canton Network application, start from https://docs.canton.network/appdev/quickstart.md. To run only a local network for your own Daml code, without building the QuickStart demo, see https://docs.canton.network/sdks-tools/development-tools/localnet.md.

# DA.Date

> Reference documentation for Daml module DA.Date.

Daml module

# DA.Date

This module provides a set of functions to manipulate Date values.

Daml

[Updated 3.5.1](#history-updated-3-5-1)

Module
DA.Date

Latest release
3.7.5

## Data Types

### `data DayOfWeek`

Constructors:

* `Monday`

- `Tuesday`

* `Wednesday`

- `Thursday`

* `Friday`

- `Saturday`

* `Sunday`

Instances:

* instance `Serializable` [`DayOfWeek`](#type-da-date-types-dayofweek-18120)
* instance [`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) [`DayOfWeek`](#type-da-date-types-dayofweek-18120)
* instance [`Ord`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-ord-6395) [`DayOfWeek`](#type-da-date-types-dayofweek-18120)
* instance [`Bounded`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-enum-bounded-34379) [`DayOfWeek`](#type-da-date-types-dayofweek-18120)
* instance [`Enum`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-enum-enum-63048) [`DayOfWeek`](#type-da-date-types-dayofweek-18120)
* instance [`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) [`DayOfWeek`](#type-da-date-types-dayofweek-18120)

### `data Month`

The `Month` type represents a month in the Gregorian calendar.

Note that, while `Month` has an `Enum` instance, the `toEnum` and `fromEnum`
functions start counting at 0, i.e. `toEnum 1 :: Month` is `Feb`.

Constructors:

* `Jan`

- `Feb`

* `Mar`

- `Apr`

* `May`

- `Jun`

* `Jul`

- `Aug`

* `Sep`

- `Oct`

* `Nov`

- `Dec`

Instances:

* instance `Serializable` [`Month`](#type-da-date-types-month-22803)
* instance [`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) [`Month`](#type-da-date-types-month-22803)
* instance [`Ord`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-ord-6395) [`Month`](#type-da-date-types-month-22803)
* instance [`Bounded`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-enum-bounded-34379) [`Month`](#type-da-date-types-month-22803)
* instance [`Enum`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-enum-enum-63048) [`Month`](#type-da-date-types-month-22803)
* instance [`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) [`Month`](#type-da-date-types-month-22803)

## Functions

### `addDays`

`addDays` : [`Date`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-date-32253) -> [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Date`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-date-32253)

Add the given number of days to a date.

### `subtractDays`

`subtractDays` : [`Date`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-date-32253) -> [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Date`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-date-32253)

Subtract the given number of days from a date.

`subtractDays d r` is equivalent to `addDays d (- r)`.

### `subDate`

`subDate` : [`Date`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-date-32253) -> [`Date`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-date-32253) -> [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)

Returns the number of days between the two given dates.

### `dayOfWeek`

`dayOfWeek` : [`Date`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-date-32253) -> [`DayOfWeek`](#type-da-date-types-dayofweek-18120)

Returns the day of week for the given date.

### `fromGregorian`

`fromGregorian` : ([`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261), [`Month`](#type-da-date-types-month-22803), [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)) -> [`Date`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-date-32253)

Constructs a `Date` from the triplet `(year, month, days)`.

### `toGregorian`

`toGregorian` : [`Date`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-date-32253) -> ([`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261), [`Month`](#type-da-date-types-month-22803), [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261))

Turn `Date` value into a `(year, month, day)` triple, according
to the Gregorian calendar.

### `date`

`date` : [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Month`](#type-da-date-types-month-22803) -> [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Date`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-date-32253)

Given the three values (year, month, day), constructs a `Date` value.
`date y m d` turns the year `y`, month `m`, and day `d` into a `Date` value.
Raises an error if `d` is outside the range `1 .. monthDayCount y m`.

### `isLeapYear`

`isLeapYear` : [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Bool`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-bool-66265)

Returns `True` if the given year is a leap year.

### `fromMonth`

`fromMonth` : [`Month`](#type-da-date-types-month-22803) -> [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)

Get the number corresponding to given month. For example, `Jan` corresponds
to `1`, `Feb` corresponds to `2`, and so on.

### `monthDayCount`

`monthDayCount` : [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Month`](#type-da-date-types-month-22803) -> [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261)

Get number of days in the given month in the given year, according to Gregorian calendar.
This does not take historical calendar changes into account (for example, the
moves from Julian to Gregorian calendar), but does count leap years.

### `datetime`

`datetime` : [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Month`](#type-da-date-types-month-22803) -> [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Int`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-ghc-types-int-37261) -> [`Time`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-time-63886)

Constructs an instant using `year`, `month`, `day`, `hours`, `minutes`, `seconds`.

### `toDateUTC`

`toDateUTC` : [`Time`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-time-63886) -> [`Date`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-date-32253)

Extracts UTC date from UTC time.

This function will truncate Time to Date, but in many cases it will not return the date you really want.
The reason for this is that usually the source of Time would be getTime, and getTime returns UTC, and most likely
the date you want is something local to a location or an exchange. Consequently the date retrieved this way would be
yesterday if retrieved when the market opens in say Singapore.

## Orphan Typeclass Instances

* instance [`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) [`DayOfWeek`](#type-da-date-types-dayofweek-18120)

* instance [`Ord`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-ord-6395) [`DayOfWeek`](#type-da-date-types-dayofweek-18120)

* instance [`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) [`DayOfWeek`](#type-da-date-types-dayofweek-18120)

* instance [`Enum`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-enum-enum-63048) [`DayOfWeek`](#type-da-date-types-dayofweek-18120)

* instance [`Bounded`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-enum-bounded-34379) [`DayOfWeek`](#type-da-date-types-dayofweek-18120)

* instance [`Eq`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-eq-22713) [`Month`](#type-da-date-types-month-22803)

* instance [`Ord`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-classes-ord-6395) [`Month`](#type-da-date-types-month-22803)

* instance [`Show`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-show-show-65360) [`Month`](#type-da-date-types-month-22803)

* instance [`Enum`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-enum-enum-63048) [`Month`](#type-da-date-types-month-22803)

* instance [`Bounded`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-enum-bounded-34379) [`Month`](#type-da-date-types-month-22803)

* instance [`Enum`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-enum-enum-63048) [`Date`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-date-32253)

* instance [`Bounded`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#class-ghc-enum-bounded-34379) [`Date`](https://docs.canton.network/appdev/reference/daml-standard-library/prelude#type-da-internal-lf-date-32253)

## History

Updated
`3.5.1`

Module declarations or documentation updated.
