Skip to content

Cooperate with Unitful.jl #59

@PatrickHaecker

Description

@PatrickHaecker

I think it would feel very natural to cooperate with the time related quantities of Unitful.jl (possibly as a package extension). It might be worth going through NanoDates.jl's complete API to check whether there are more opportunities, but in the following I'll focus on my specific use case.

A Unitful.Quantity containing time information relative to the Unix epoch needs to be converted to a NanoDate. I currently effectively uconvert it to a specific SI prefix, remove the unit with ustrip and then hand the result to the correct unix*2nanodate. This feels quite an indirect way to combine two packages which both handle time where one package already provides the prefix the other package needs.

I think some definitions like

unix2nanodate(x::Quantity{Int, Unitful.𝐓, Unitful.µs |> typeof}) = x |> ustrip |> unixmicros2nanodate

could hide this API friction. There might be better ways (I do not know Unitful.jl too well), but this should at least work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions