Skip to content

Expr CalendarDiffTime -> Expr Double ? #367

@Philoustic

Description

@Philoustic

Hi,

I’m trying to convert an Expr CalendarDiffTime (which is an output of diffTime) to an Expr Double.

I have a function calendarDiffTimeToDoubleDays that works for converting from CalendarTime to Double.
However, since Expr isn’t a Functor, I’m not sure how to apply this conversion directly to the Expr type.

calendarDiffTimeToDoubleDays :: CalendarDiffTime -> Double
calendarDiffTimeToDoubleDays (CalendarDiffTime cmonths ctime) =
    monthsToDays + picosToDay
  where
    -- Convert months to days (approximation)
    monthsToDays = fromIntegral cmonths * 30.436875
    
    -- Convert picosecondes to days
    picosToDay = realToFrac $ ctime / nominalDay

Is there a way to achieve this transformation, or would I need to approach it differently?

Thanks for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions