View Source Chi2fit.Times (Chi-SquaredFit v2.0.2)
Link to this section Summary
Functions
Adjusts the times to working hours and/or work days.
Returns a Stream
that generates a stream of dates.
Maps the date to weekdays such that weekends are eliminated; it does so with respect to a given Saturday
Maps the time of a day into the working hour period
Counts the number of dates (datelist
) that is between consecutive dates in intervals
and returns the result as a list of numbers.
Returns a list of time differences (assumes an ordered list as input)
Link to this section Functions
@spec adjust_times(Enumerable.t(), options :: Keyword.t()) :: Enumerable.t()
Adjusts the times to working hours and/or work days.
options
Options
`workhours` - a 2-tuple containing the starting and ending hours of the work day (defaults
to {8.0, 18.0})
`epoch` - the epoch to which all data elements are relative (defaults to 1970-01-01)
`saturday` - number of days since the epoch that corresponds to a Saturday (defaults
to 9)
`correct` - whether to correct the times for working hours and weekdays; possible values
`:worktime`, `:weekday`, `:"weekday+worktime"` (defaults to `false`)
@spec intervals(options :: Keyword.t()) :: Enumerable.t()
Returns a Stream
that generates a stream of dates.
examples
Examples
iex> intervals(end: ~D[2019-06-01]) |> Enum.take(4)
[~D[2019-06-01], ~D[2019-05-16], ~D[2019-05-01], ~D[2019-04-16]]
iex> intervals(end: ~D[2019-06-01], type: :weekly) |> Enum.take(4)
[~D[2019-06-01], ~D[2019-05-18], ~D[2019-05-04], ~D[2019-04-20]]
iex> intervals(end: ~D[2019-06-01], type: :weekly, weeks: 1) |> Enum.take(4)
[~D[2019-06-01], ~D[2019-05-25], ~D[2019-05-18], ~D[2019-05-11]]
iex> intervals(end: ~D[2019-06-01], type: :weekly, weeks: [3,2]) |> Enum.take(4)
[~D[2019-06-01], ~D[2019-05-11], ~D[2019-04-27], ~D[2019-04-13]]
@spec map2weekdays(t :: number(), sat :: pos_integer()) :: number()
Maps the date to weekdays such that weekends are eliminated; it does so with respect to a given Saturday
example
Example
iex> map2weekdays(43568.123,43566)
43566.123
iex> map2weekdays(43574.123,43566)
43571.123
Maps the time of a day into the working hour period
Scales the resulting part of the day between 0..1.
arguments
Arguments
`t` - date and time of day as a float; the integer part specifies the day and the fractional part the hour of the day
`startofday` - start of the work day in hours
`endofday` - end of the working day in hours
example
Example
iex> map2workhours(43568.1, 8, 18)
43568.0
iex> map2workhours(43568.5, 8, 18)
43568.4
@spec throughput(intervals :: Enumerable.t(), datelist :: [NaiveDateTime.t()]) :: [ number() ]
Counts the number of dates (datelist
) that is between consecutive dates in intervals
and returns the result as a list of numbers.
@spec time_diff(data :: Enumrable.t(), options :: Keyword.t()) :: Enumerable.t()
Returns a list of time differences (assumes an ordered list as input)
options
Options
`cutoff` - time differences below the cutoff are changed to the cutoff value (defaults to `0.01`)
`drop?` - whether to drop time differences below the cutoff (defaults to `false`)