Reference

Contents

Index

TimeFloats.fromfloatFunction
fromfloat(x::Real, ::Type{S}) where {S<:FixedPeriod}

Convert x S to a CompoundPeriod. S is any of the types in the Dates.FixedPeriod union-type (i.e. Nanosecond, Microsecond, Millisecond, Second, Minute, Hour, Day, or Week). The resulting CompoundPeriod will include the largest FixedPeriods needed to accurately describe x.

Examples

julia> using Dates

julia> fromfloat(1, Second)
1 second
source
TimeFloats.fromsecondMethod
fromsecond(x::Real)

Convert x seconds to a CompoundPeriod. The resulting CompoundPeriod will include the largest FixedPeriods needed to accurately describe x.

Examples

julia> using Dates

julia> fromsecond(1001//1000)
1 second, 1 millisecond

julia> fromsecond(1.5)
1 second, 500 milliseconds

Notice

Any accuracy after the 9th decimal place of x is ignored for nanoseconds.

julia> using Dates

julia> fromsecond(0.0000000019)
1 nanosecond
source
TimeFloats.tofloatFunction
tofloat(::Type{T}, x) where {T<:FixedPeriod}

Convert x to a float representation of x as a T. T is any of the types in the Dates.FixedPeriod union-type (i.e. Nanosecond, Microsecond, Millisecond, Second, Minute, Hour, Day, or Week). x can be any of the types in the Dates.FixedPeriod union-type, Time, or Dates.CompoundPeriod.

Examples

julia> using Dates

julia> tofloat(Millisecond, Second(1))
1000.0
source
TimeFloats.tosecondMethod
tosecond(x)

Convert x to a float representation of x in seconds. x can be any type in the Dates.FixedPeriod union-type (i.e. Nanosecond, Microsecond, Millisecond, Second, Minute, Hour, Day, and Week), Time, or Dates.CompoundPeriod.

Examples

julia> using Dates

julia> tosecond(Millisecond(1500))
1.5
source