Time and date functions¶
The following functions operate on the built-in type DateTime
for timestamps.
DateTime::addSeconds : DateTime -> Int -> DateTime
¶
The function DateTime::addSeconds
adds seconds to a timestamp.
Examples¶
val a = DateTime::addSeconds #2017-12-24T13:37:00Z# 60
// = #2017-12-24T13:38:00Z#
DateTime::addDays : DateTime -> Int -> DateTime
¶
Add days to a timestamp.
Examples¶
val now = #2018-02-08T10:00:00Z#
val tomorrow = DateTime::addDays now 1
// = #2018-02-09T10:00:00Z#
val yesterday = DateTime::addDays now (0 - 1)
// = #2018-02-07T10:00:00Z#
DateTime::Components
¶
The type DateTime::Components
represents the components of a DateTime
value, e.g., year, month, etc.
The DateTime::Components
is a built-in type.
The definition is
module DateTime {
type Components {
year : Int,
month : Int,
day : Int,
hour : Int,
minute : Int,
second : Int
}
}
DateTime::components : DateTime -> DateTime::Components
¶
Extract a DateTime::Components
representation from a DateTime
value.
Examples¶
val a = DateTime::components #2018-02-08T10:15:30Z#
// = DateTime::Components {
// year = 2018,
// month = 2,
// day = 8,
// hour = 10,
// minute = 15,
// second = 30
// }
DateTime::DayOfWeek
¶
The built-in type DateTime::DayOfWeek
represents the days of the week.
Its definition is
module DateTime {
type DayOfWeek
| Monday
| Tuesday
| Wednesday
| Thursday
| Friday
| Saturday
| Sunday
}
DateTime::dayOfWeek : DateTime -> DateTime::DayOfWeek
¶
Get the day of week for a DateTime
value.
Examples¶
val monday = DateTime::dayOfWeek #2007-01-01#
// = DateTime::Monday
DateTime::dayCountFraction : DateTime::DayCountFraction -> DateTime -> DateTime -> Float
¶
Get the Day Count Fraction according to some convention, where conventions are defined as:
module DateTime {
type PaymentFrequency
| Annual
| SemiAnnual
| Quarterly
type DayCountFraction
| ActActISDA DateTime DateTime
| ActActICMA DateTime DateTime DateTime DateTime DateTime::PaymentFrequency
| Act365F DateTime DateTime
| Act360 DateTime DateTime
| Act365A DateTime DateTime
| Thirty360ISDA DateTime DateTime
| Thirty360ICMA DateTime DateTime
}
Where the first two parameters are from and to dates for the calculation. The additional parameters for ActActICMA are firstPayment, maturity, and frequency respectively.
Examples¶
val dcf = DateTime::dayCountFraction (DateTime::ActActISDA #2007-12-28T00:00:00Z# #2008-02-28T00:00:00Z#)
// = 4/365 + 58/366 ~ 0.16942884946478