Fooling Program's Evaluation of Current Time Zone Offset

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Fooling Program's Evaluation of Current Time Zone Offset

Tucsonjhall
This post was updated on .
I have an app that has many references to a comparison function in my
DateUtilities to see if two dates are on the same day. Unfortunately, the
logical approach is used a couple hundred times in my application. Now I see
that in unusual circumstances a user may want to count an event that starts
at midnight of some day as an event that happens on the physical previous
day. So, for instance, they may have games at 9PM, 10PM, 11PM, and 12PM. But
my baked-in logic would always say that 12PM is the next day.

The only approach I can think of is to temporarily fool the program into
thinking the UTC offset is different by 1 hour then return it to the usual
offset once evaluation of same day events is completed.

Any suggestions on how to temporarily change the perceived offset? I know
that ActionScript has a timeZoneOffset but that's read only. My attempts so
far have failed.



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Fooling Program's Evaluation of Current Time Zone Offset

Alex Harui-2
I assume you meant 12AM?

I'm not an expert on Date handling, but my instinct would be to convert the Date to Date.time() (milliseconds since Jan 1, 1970) and figure out the Date.time() that corresponds to the boundary between days.  And then you are either past that number or not.

HTH,
-Alex

´╗┐On 11/2/19, 4:50 PM, "Tucsonjhall" <[hidden email]> wrote:

    I have an app that has many references to a comparison function in my
    DateUtilities to see if two dates are on the same day. Unfortunately, the
    logical approach is used a couple hundred times in my application. Now I see
    that in unusual circumstances a user may want to count an event that starts
    at midnight of some day as an event that happens on the physical previous
    day. So, for instance, they may have games at 9PM, 10PM, 11PM, and 12PM. But
    my baked-in logic would always say that 12PM is the next day.
   
    The only approach I can think of is to temporarily fool the program into
    thinking the UTC offset is different by 1 hour then return it to the usual
    offset once evaluation of same day events is completed.
   
    Any suggestions on how to temporarily change the perceived offset? I know
    that ActionScript has a timeZoneOffset but that's read only. My attempts so
    far have failed.
   
   
   
    --
    Sent from: https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-flex-users.2333346.n4.nabble.com%2F&amp;data=02%7C01%7Caharui%40adobe.com%7C0e3757259af44f4b1e6408d75fef67d9%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C1%7C637083354160582388&amp;sdata=oIddXuZ0mF6c3Q%2B48k96sB09Htf2pbLM3EVnz0yJFWw%3D&amp;reserved=0
   

Reply | Threaded
Open this post in threaded view
|

Re: Fooling Program's Evaluation of Current Time Zone Offset

Tucsonjhall
I think you understood the problem when you were answering but to clarify, I
meant a 12AM game, not 12PM game, is the problem child for me. I'll
experiment with some approaches suggested by your comments. Thanks



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/