DateShifting
- DateShifting.datetime_intervals
- DateShifting.datetime_intervals
- DateShifting.sequence_and_random_date_shift
- DateShifting.sequence_and_random_date_shift
DateShifting.datetime_intervals — Methoddatetime_intervals(input_dt_list::Vector{Dates.DateTime};
                   round_to::Dates.Period)Arguments
- input_dt_list::Vector{Dates.DateTime}: A vector of- DateTimes.
Keyword Arguments
- round_to::Dates.Period: Resolution to which all intervals should be rounded.
Example
julia> using Dates
julia> using DateShifting
julia> dates = [
           DateTime("2000-01-01T00:00:00"),
           DateTime("2000-02-01T00:00:00"),
           DateTime("2000-01-05T00:00:00"),
           DateTime("2000-01-02T04:05:06"),
           DateTime("2000-01-02T01:02:03"),
       ]
5-element Array{DateTime,1}:
 2000-01-01T00:00:00
 2000-02-01T00:00:00
 2000-01-05T00:00:00
 2000-01-02T04:05:06
 2000-01-02T01:02:03
julia> sequence, intervals = datetime_intervals(dates; round_to = Day(1))
([1, 5, 4, 3, 2], Dates.Day[0 days, 31 days, 4 days, 1 day, 1 day])
julia> sequence
5-element Array{Int64,1}:
 1
 5
 4
 3
 2
julia> intervals
5-element Array{Day,1}:
 0 days
 31 days
 4 days
 1 day
 1 dayDateShifting.datetime_intervals — Methoddatetime_intervals(input_zdt_list::Vector{TimeZones.ZonedDateTime};
                   round_to::Dates.Period)Arguments
- input_zdt_list::Vector{TimeZones.ZonedDateTime}: A vector of- ZonedDateTimes.
Keyword Arguments
- round_to::Dates.Period: Resolution to which all intervals should be rounded.
Example
julia> using Dates
julia> using DateShifting
julia> using TimeZones
julia> dates = [
           ZonedDateTime(DateTime("2000-01-01T00:00:00"), tz"America/New_York"),
           ZonedDateTime(DateTime("2000-02-01T00:00:00"), tz"America/New_York"),
           ZonedDateTime(DateTime("2000-01-05T00:00:00"), tz"America/New_York"),
           ZonedDateTime(DateTime("2000-01-02T03:05:06"), tz"America/Chicago"),
           ZonedDateTime(DateTime("2000-01-02T01:02:03"), tz"America/New_York"),
       ]
5-element Array{ZonedDateTime,1}:
 2000-01-01T00:00:00-05:00
 2000-02-01T00:00:00-05:00
 2000-01-05T00:00:00-05:00
 2000-01-02T03:05:06-06:00
 2000-01-02T01:02:03-05:00
julia> sequence, intervals = datetime_intervals(dates; round_to = Day(1))
([1, 5, 4, 3, 2], Dates.Day[0 days, 31 days, 4 days, 1 day, 1 day])
julia> sequence
5-element Array{Int64,1}:
 1
 5
 4
 3
 2
julia> intervals
5-element Array{Day,1}:
 0 days
 31 days
 4 days
 1 day
 1 dayDateShifting.sequence_and_random_date_shift — Methodsequence_and_random_date_shift(rng::Random.AbstractRNG,
                               input_dt_list::Vector{Dates.DateTime};
                               kwargs...)Arguments
- rng::Random.AbstractRNG: Random number generator that will be used for sampling.
- input_dt_list::Vector{Dates.DateTime}: A vector of- DateTimes.
Keyword Arguments
- time_zone::Dates.TimeZone: Time zone for the input dates.
- round_to::Dates.Period: Resolution to which all intervals should be rounded.
- day::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Dayshift amount will be sampled.
- hour::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Hourshift amount will be sampled.
- minute::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Minuteshift amount will be sampled.
- second::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Secondshift amount will be sampled.
- millisecond::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Millisecondshift amount will be sampled.
- microsecond::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Microsecondshift amount will be sampled.
- nanosecond::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Nanosecondshift amount will be sampled.
Example
julia> using Dates
julia> using DateShifting
julia> using Distributions
julia> using Random
julia> using TimeZones
julia> dates = [
           DateTime("2000-01-01T00:00:00"),
           DateTime("2000-02-01T00:00:00"),
           DateTime("2000-01-05T00:00:00"),
           DateTime("2000-01-02T04:05:06"),
           DateTime("2000-01-02T01:02:03"),
       ]
5-element Array{DateTime,1}:
 2000-01-01T00:00:00
 2000-02-01T00:00:00
 2000-01-05T00:00:00
 2000-01-02T04:05:06
 2000-01-02T01:02:03
julia> sequence, shifted_dates = sequence_and_random_date_shift(
           Random.GLOBAL_RNG,
           dates;
           round_to = Day(1),
           time_zone = TimeZone("America/New_York"),
           day = DiscreteUniform(-31, 31),
           hour = DiscreteUniform(-24, 24),
           minute = DiscreteUniform(-60, 60),
           second = DiscreteUniform(-60, 60),
           millisecond = DiscreteUniform(-1000, 1000),
           microsecond = DiscreteUniform(-1000, 1000),
           nanosecond = DiscreteUniform(-1000, 1000),
       )
([1, 5, 4, 3, 2], TimeZones.ZonedDateTime[ZonedDateTime(1999, 12, 5, tz"America/New_York"), ZonedDateTime(2000, 1, 5, tz"America/New_York"), ZonedDateTime(1999, 12, 9, tz"America/New_York"), ZonedDateTime(1999, 12, 6, tz"America/New_York"), ZonedDateTime(1999, 12, 6, tz"America/New_York")])
julia> sequence
5-element Array{Int64,1}:
 1
 5
 4
 3
 2
julia> shifted_dates
5-element Array{ZonedDateTime,1}:
 1999-12-05T00:00:00-05:00
 2000-01-05T00:00:00-05:00
 1999-12-09T00:00:00-05:00
 1999-12-06T00:00:00-05:00
 1999-12-06T00:00:00-05:00DateShifting.sequence_and_random_date_shift — Methodsequence_and_random_date_shift(rng::Random.AbstractRNG,
                               input_zdt_list::Vector{TimeZones.ZonedDateTime};
                               kwargs...)Arguments
- rng::Random.AbstractRNG: Random number generator that will be used for sampling.
- input_zdt_list::Vector{TimeZones.ZonedDateTime}: A vector of- ZonedDateTimes.
Keyword Arguments
- time_zone::Dates.TimeZone: Time zone to which all dates should be converted.
- round_to::Dates.Period: Resolution to which all intervals should be rounded.
- day::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Dayshift amount will be sampled.
- hour::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Hourshift amount will be sampled.
- minute::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Minuteshift amount will be sampled.
- second::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Secondshift amount will be sampled.
- millisecond::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Millisecondshift amount will be sampled.
- microsecond::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Microsecondshift amount will be sampled.
- nanosecond::::Union{Distributions.Sampleable, Nothing}: Probability distribution from which the- Nanosecondshift amount will be sampled.
Example
julia> using Dates
julia> using DateShifting
julia> using Distributions
julia> using Random
julia> using TimeZones
julia> dates = [
           ZonedDateTime(DateTime("2000-01-01T00:00:00"), tz"America/New_York"),
           ZonedDateTime(DateTime("2000-02-01T00:00:00"), tz"America/New_York"),
           ZonedDateTime(DateTime("2000-01-05T00:00:00"), tz"America/New_York"),
           ZonedDateTime(DateTime("2000-01-02T03:05:06"), tz"America/Chicago"),
           ZonedDateTime(DateTime("2000-01-02T01:02:03"), tz"America/New_York"),
       ]
5-element Array{ZonedDateTime,1}:
 2000-01-01T00:00:00-05:00
 2000-02-01T00:00:00-05:00
 2000-01-05T00:00:00-05:00
 2000-01-02T03:05:06-06:00
 2000-01-02T01:02:03-05:00
julia> sequence, shifted_dates = sequence_and_random_date_shift(
           Random.GLOBAL_RNG,
           dates;
           round_to = Day(1),
           time_zone = TimeZone("America/New_York"),
           day = DiscreteUniform(-31, 31),
           hour = DiscreteUniform(-24, 24),
           minute = DiscreteUniform(-60, 60),
           second = DiscreteUniform(-60, 60),
           millisecond = DiscreteUniform(-1000, 1000),
           microsecond = DiscreteUniform(-1000, 1000),
           nanosecond = DiscreteUniform(-1000, 1000),
       )
([1, 5, 4, 3, 2], TimeZones.ZonedDateTime[ZonedDateTime(1999, 12, 5, tz"America/New_York"), ZonedDateTime(2000, 1, 5, tz"America/New_York"), ZonedDateTime(1999, 12, 9, tz"America/New_York"), ZonedDateTime(1999, 12, 6, tz"America/New_York"), ZonedDateTime(1999, 12, 6, tz"America/New_York")])
julia> sequence
5-element Array{Int64,1}:
 1
 5
 4
 3
 2
julia> shifted_dates
5-element Array{ZonedDateTime,1}:
 1999-12-05T00:00:00-05:00
 2000-01-05T00:00:00-05:00
 1999-12-09T00:00:00-05:00
 1999-12-06T00:00:00-05:00
 1999-12-06T00:00:00-05:00