# Why there is no TimeOfDay data type in DAML?

**URL:** <https://forum.canton.network/t/why-there-is-no-timeofday-data-type-in-daml/6862>\
**Category:** App Development\
**Tags:** daml, features and bugs\
**Created:** [September 21, 2023, 8:45am UTC](https://forum.canton.network/t/why-there-is-no-timeofday-data-type-in-daml/6862 "2023-09-21T08:45:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cohen.avraham](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@cohen.avraham](https://forum.canton.network/u/cohen.avraham)\
**Post date:** [September 21, 2023, 8:45am UTC](https://forum.canton.network/t/why-there-is-no-timeofday-data-type-in-daml/6862/1 "2023-09-21T08:45:58Z")

</div>

G-d willing

Hello,  
I want to ask why there is no specific data type that only represent the time, It is a primitive data type, and it is needed in many use cases within the business flow.  
In Haskell this is called `TimeOfDay`.

Thanks,

---

<div class="post-metadata">

**Author:** ![Ben\_M](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/ben_m/32/3080_2.png) [@Ben\_M](https://forum.canton.network/u/Ben_M)\
**Post date:** [September 25, 2023, 1:31am UTC](https://forum.canton.network/t/why-there-is-no-timeofday-data-type-in-daml/6862/2 "2023-09-25T01:31:30Z")

</div>

Hi Avraham,

I cannot state why the decision was made to not include a specific Data Type to represent Time of Day, but there is an example in the documents whereby you can construct a data type titled `timeofday` yourself.

Please see the code in the [Assertions](https://docs.daml.com/daml/intro/5_Restrictions.html#assertions) section in the [Adding Constraints to a Contract](https://docs.daml.com/daml/intro/5_Restrictions.html#add-constraints-to-a-contract).

```haskell
choice Redeem
      : ()
      controller owner
      do
        now <- getTime
        let
          today = toDateUTC now
          dow = dayOfWeek today
          timeofday = now `subTime` time today 0 0 0
          hrs = convertRelTimeToMicroseconds timeofday / 3600000000
        if (hrs < 8 || hrs > 18) then
          abort $ "Cannot redeem outside business hours. Current time: " <> show timeofday
        else case dow of
          Saturday -> abort "Cannot redeem on a Saturday."
          Sunday -> abort "Cannot redeem on a Sunday."
          _ -> return ()

```

As you can see there is a lot of flexibility available with the Time function itself. Hope this gives you some context.

---

<div class="post-metadata">

**Author:** ![Andrae](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/andrae/32/395_2.png) [@Andrae](https://forum.canton.network/u/Andrae)\
**Post date:** [September 25, 2023, 2:56am UTC](https://forum.canton.network/t/why-there-is-no-timeofday-data-type-in-daml/6862/3 "2023-09-25T02:56:33Z")

</div>

If you really want Haskell’s `TimeOfDay` then one option is to convert the TimeOfDay module from hackage to Daml ([https://hackage.haskell.org/package/time-1.12.2/docs/src/Data.Time.LocalTime.Internal.TimeOfDay.html](https://hackage.haskell.org/package/time-1.12.2/docs/src/Data.Time.LocalTime.Internal.TimeOfDay.html)).

This is a BSD-2 licensed module, so the licensing shouldn’t be a problem. `DiffTime` becomes `RelTime` in Daml; `Rational` becomes `BigDecimal` or a suitable `Numeric n` type, depending on your need, and the strictness support is of course not relevant to Daml. Other than that the rest should transliterate with almost no changes.

Most of the important hackage packages are BSD licensed, so lifting libraries like this is something I do as a matter of course when the need arises.
