Consider the following scenario.
Suppose I consider time range from TimeObject[{18,30,0}] to TimeObject[{22,30,0}] on Weekdays and TimeObject[{18,0,0}] to TimeObject[{22,0,0}] on Weekends as peak time for something.
Now given a date range DateObject[{2019,7,18,20,12,30}] to DateObject[{2019,7,31,18,45,30}]. I want to find the intervals of peak times encountered in this range. Also I want to find the proportion of time spend in peak? What is the easiest way to calculate this using the Mathematica's Date and Time functionality.
Does Wolfram language provide a symbolic wrapper to represent a date/time interval and also a disjoint but periodic intervals of time?
Thank you @kglr it works! Although "Duration" property does not exactly calculate what I want but the following workaround works.
With[{
interval=DateTime`DateInterval[{3755358615, 3755368800}, {3755440800, 3755455200}, {3755527200, 3755540710}, True]
},
{
Query[Apply[Plus]@*All,Apply[Subtract]@*Reverse]@interval["Dates"],
interval["Duration"],
DateObject[{2019,1,1,19,10,15},"Instant","Gregorian",1.`]-DateObject[{2019,1,3,21,45,10},"Instant","Gregorian",1.`]
}
]









Names["*`*Date*Interval*"]:) – kglr Jul 30 '19 at 20:33