Re: Did April go missing in Asia/Amman?

2016-04-25 Thread Bill Moseley
Thank you Eric and Zefram! On Sun, Apr 24, 2016 at 10:11 AM, Eric Brine wrote: > Released DateTimeX::Start to cpan > http://search.cpan.org/perldoc?DateTimeX::Start > > On Sat, Apr 23, 2016 at 5:29 PM, Eric Brine wrote: > >> Thanks! Yeah, knowing

Re: Did April go missing in Asia/Amman?

2016-04-24 Thread Eric Brine
Released DateTimeX::Start to cpan http://search.cpan.org/perldoc?DateTimeX::Start On Sat, Apr 23, 2016 at 5:29 PM, Eric Brine wrote: > Thanks! Yeah, knowing that, I can easily make my code only consider > minutes. I'll also incorporate your "rd" optimziation > > On Sat, Apr

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Eric Brine
Thanks! Yeah, knowing that, I can easily make my code only consider minutes. I'll also incorporate your "rd" optimziation On Sat, Apr 23, 2016 at 5:16 PM, Zefram wrote: > Eric Brine wrote: > >Thanks. I'll study this. I didn't think dividing by 60, adding 60 and > >subtracting

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Zefram
Eric Brine wrote: >Thanks. I'll study this. I didn't think dividing by 60, adding 60 and >subtracting 60 was safe before of leap seconds. POSIX time, what DateTime calls "epoch" time, doesn't count leap seconds. Each multiple of 60 corresponds to the top of a UTC minute. -zefram

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Eric Brine
On Sat, Apr 23, 2016 at 4:56 PM, Zefram wrote: > Eric Brine wrote: > >The binary search found: > ... > >2013-11-03T03:45:00 UTC > >2013-11-03T04:07:30 UTC > > You should only examine integral minutes. Truncate to the minute > when bisecting, before you pass your bisected time

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Zefram
Eric Brine wrote: >The binary search found: ... >2013-11-03T03:45:00 UTC >2013-11-03T04:07:30 UTC You should only examine integral minutes. Truncate to the minute when bisecting, before you pass your bisected time to DateTime. Or, to avoid fractions entirely, extend the search radius to 2048

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Eric Brine
Then I don't understand your algorithm. I perform a binary search on epoch times with two UTC dt as bounds. The result is 2013-11-02T23:59:03 in the desired time zone. On Sat, Apr 23, 2016 at 4:08 PM, Zefram wrote: > Eric Brine wrote: > >00:00:04 <--- Starting from this > >

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Zefram
Eric Brine wrote: >00:00:04 <--- Starting from this You shouldn't be getting such a time at any point in the algorithm I was proposing. -zefram

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Eric Brine
On Sat, Apr 23, 2016 at 3:52 PM, Zefram wrote: > Eric Brine wrote: > >I can't figure out how to search only down to the minute without causing > it > >to find the wrong answer on days with two midnights. > > In those fairly common cases, where DST ending causes time to jump back

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Zefram
Eric Brine wrote: >I can't figure out how to search only down to the minute without causing it >to find the wrong answer on days with two midnights. In those fairly common cases, where DST ending causes time to jump back from 01:00 to 00:00, you want to consistently get the earlier midnight. This

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Eric Brine
On Sat, Apr 23, 2016 at 3:42 PM, Eric Brine wrote: > On Fri, Apr 22, 2016 at 8:04 PM, Zefram wrote: > >> 18 steps >> of binary search gets you down to the second, but actually modern zones >> are always on integral-minute offsets, so you could look only at

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Eric Brine
On Fri, Apr 22, 2016 at 8:04 PM, Zefram wrote: > 18 steps > of binary search gets you down to the second, but actually modern zones > are always on integral-minute offsets, so you could look only at integral > minutes and take only 12 steps. For each UT time you try, convert it

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Eric Brine
On Sat, Apr 23, 2016 at 2:58 PM, Eric Brine wrote: > On Sat, Apr 23, 2016 at 2:57 PM, Eric Brine wrote: > >> Zephram, could you verify the updated code: >> >> http://stackoverflow.com/a/21000824/589924 >> >> Assumptions: >> >> >>- There is no dt to

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Eric Brine
On Sat, Apr 23, 2016 at 2:57 PM, Eric Brine wrote: > Zephram, could you verify the updated code: > > http://stackoverflow.com/a/21000824/589924 > > Assumptions: > > >- There is no dt to which one can add time to obtain a dt with an >earlier date. >- In no time

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Eric Brine
Zephram, could you verify the updated code: http://stackoverflow.com/a/21000824/589924 Assumptions: - There is no dt to which one can add time to obtain a dt with an earlier date. - In no time zone does a date starts more than 48*60*60 seconds before the date starts in UTC. - In

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Zefram
Bill Moseley wrote: >The code Eric pointed me to sets the hour to 12 on a floating $dt and then >sets the timezone. Sounds like there's cases where that could still fail. Right, that's broken. That's not the algorithm I was proposing. You should search among *UT* times, and the only kind of

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Bill Moseley
On Sat, Apr 23, 2016 at 10:14 AM, Zefram wrote: > Bill Moseley wrote: > >hour=> 12, # Assume this exists > > This does not always exist. Africa/Khartoum on 2000-01-15, for example. > In fact, thanks to cases such as Pacific/Apia on 2011-12-30, not only is > there no

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Zefram
Bill Moseley wrote: >hour=> 12, # Assume this exists This does not always exist. Africa/Khartoum on 2000-01-15, for example. In fact, thanks to cases such as Pacific/Apia on 2011-12-30, not only is there no hour that exists on every day in every zone, there are actually some zone days

Re: Did April go missing in Asia/Amman?

2016-04-23 Thread Eric Brine
On Fri, Apr 22, 2016 at 8:04 PM, Zefram wrote: > Bill Moseley wrote: > >In other words, I'm trying to find the start and end times for the current > >month based on a given timezone and then use those in my database query. > > You can perform a binary search on UT times, looking

Re: Did April go missing in Asia/Amman?

2016-04-22 Thread Bill Moseley
Thanks -- that makes sense. My error not considering that 00:00:00 might not exist on the first of the month. Suggestion how best to do this? I'm running queries where I want to fetch rows with a timestamp within a given month -- but that time range should be in the time zone of the user I'm

Re: Did April go missing in Asia/Amman?

2016-04-22 Thread Zefram
Bill Moseley wrote: >Why can't I truncate to the month? Because 2016-04-01T00:00:00 didn't exist in Asia/Amman. Its DST rules include a switch from winter time to summer time at 24:00 on the last Thursday in March. This has the effect of skipping the hour from 00:00 to 01:00 on some Friday