- Overview
- Tutorials
- Getting started
- Get started with Canton and the JSON Ledger API
- Get Started with Canton, the JSON Ledger API, and TypeScript
- Get started with Canton Network App Dev Quickstart
- Get started with smart contract development
- Basic contracts
- Test templates using Daml scripts
- Build the Daml Archive (.dar) file
- Data types
- Transform contracts using choices
- Add constraints to a contract
- Parties and authority
- Compose choices
- Handle exceptions
- Work with dependencies
- Functional programming 101
- The Daml standard library
- Test Daml contracts
- Next steps
- Application development
- Getting started
- Development how-tos
- Component how-tos
- Explanations
- References
- Application development
- Smart contract development
- Daml language cheat sheet
- Daml language reference
- Daml standard library
- DA.Action.State.Class
- DA.Action.State
- DA.Action
- DA.Assert
- DA.Bifunctor
- DA.Crypto.Text
- DA.Date
- DA.Either
- DA.Exception
- DA.Fail
- DA.Foldable
- DA.Functor
- DA.Internal.Interface.AnyView.Types
- DA.Internal.Interface.AnyView
- DA.List.BuiltinOrder
- DA.List.Total
- DA.List
- DA.Logic
- DA.Map
- DA.Math
- DA.Monoid
- DA.NonEmpty.Types
- DA.NonEmpty
- DA.Numeric
- DA.Optional
- DA.Record
- DA.Semigroup
- DA.Set
- DA.Stack
- DA.Text
- DA.TextMap
- DA.Time
- DA.Traversable
- DA.Tuple
- DA.Validation
- GHC.Show.Text
- GHC.Tuple.Check
- Prelude
- Smart contract upgrading reference
- Glossary of concepts
DA.Date¶
This module provides a set of functions to manipulate Date values. The bounds for Date are 0001-01-01T00:00:00.000000Z and 9999-12-31T23:59:59.999999Z.
Data Types¶
data DayOfWeek
data Month
The
Month
type represents a month in the Gregorian calendar.Note that, while
Month
has anEnum
instance, thetoEnum
andfromEnum
functions start counting at 0, i.e.toEnum 1 :: Month
isFeb
.
Functions¶
- subtractDays
-
Subtract the given number of days from a date.
subtractDays d r
is equivalent toaddDays d (- r)
.
- fromGregorian
-
Constructs a
Date
from the triplet(year, month, days)
.
- toGregorian
-
Turn
Date
value into a(year, month, day)
triple, according to the Gregorian calendar.
- date
-
Given the three values (year, month, day), constructs a
Date
value.date y m d
turns the yeary
, monthm
, and dayd
into aDate
value. Raises an error ifd
is outside the range1 .. monthDayCount y m
.
- isLeapYear
-
Returns
True
if the given year is a leap year.
- fromMonth
-
Get the number corresponding to given month. For example,
Jan
corresponds to1
,Feb
corresponds to2
, and so on.
- monthDayCount
-
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
: Int -> Month -> Int -> Int -> Int -> Int -> Time
Constructs an instant using
year
,month
,day
,hours
,minutes
,seconds
.
- toDateUTC
-
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.