[Gambas-user] forcing time zone localization

Benoît Minisini gambas at ...1...
Sun Feb 3 14:03:27 CET 2013


Le 03/02/2013 10:28, Ian Haywood a écrit :
> On Sun, Feb 3, 2013 at 7:11 PM, Kevin Fishburne
> <kevinfishburne at ...1887...> wrote:
> \
>
>> The date/time is sent/received as a float and stays synchronized. The
>> problem is (as you say) when the float is converted to a string the time
>> zone is applied. I need a way to print
>>
>> Format$(CDate(DateCurrent), "mmmm d, yyyy, hh:nn:AM/PM")
>>
>> without the time zone being applied, or with a specific TZ applied.
>> "DateCurrent" is the float. I'm trying not to custom create a calendar
>> and complicate Format$ with it, but specify a time zone. The server is
>> fine, but the client applies local TZ and DST rules and fouls the
>> formatting of Format$.
>>
>> Hope that makes sense, and thanks.
> presumably the float is seconds since epoch or similar.

Yes. Epoch is a virtual date about 10000 years before now.

> so calculate the difference between the local time and server time in seconds
> and subtract it from the float value before display, this
> "counteracts" the time zone
> adjustment applied by the client OS
>
> Ian
>

To get the current timezone, you do Round(Frac(Date(Now)) * 24). Then 
you can use this value to convert a date to/from UTC.

Regards,

-- 
Benoît Minisini




More information about the User mailing list