> CDate uses UTC and, without the time information in the string, it would
store midnight. Format uses local time.

That is definitely part of the issue.  My local time is GMT-04, and here's
what I get when specifying the time in my test:

Test date: 5/4/2018 03:59:00 Formatted: 05/03/18 Thu
Test date: 5/4/2018 04:00:00 Formatted: 05/04/18 Fri

However, if I look at time in the results, the difference isn't exactly the
offset:
Test date: 5/4/2018 03:59:00 Formatted: 05/03/18 23:05:00  Difference:
4:54:00
Test date: 5/4/2018 04:00:00 Formatted: 05/04/18 00:05:00  Difference:
3:55:00
Test date: 5/4/2018 00:00:00 Formatted: 05/03/18 20:05:00  Difference:
3:55:00

The offset isn't an even number of hours. What's also odd is that this was
never a problem before about a week ago.  This code is many years old, and
the problem suddenly began occurring with compiled code.


On Sat, May 19, 2018 at 10:15 AM, Gianluigi <bagone...@gmail.com> wrote:

> But Debug (Print) localizes!
>
> However, with the dates I always get lost :-(
>
> Regards
> Gianluigi
>
>
> 2018-05-19 16:00 GMT+02:00 T Lee Davidson <t.lee.david...@gmail.com>:
>
> > CDate uses UTC and, without the time information in the string, it would
> > store midnight. Format uses local time.
> >
> > So, anyone in a time zone behind UTC will get the previous day printed.
> > Try this format string:
> > zTestResult = Format(CDate(zTestDate), "mm/dd/yy hh:nn ddd")
> >
> > Does the difference in hours match your timezone offset?
> >
> >
> > --
> > Lee
> >
> >
> > On 05/19/2018 09:08 AM, Gianluigi wrote:
> > > I think it depends on your version of Gambas, I get the correct result
> > with
> > > the master:
> > >
> > >   Dim zTestDate As String
> > >   Dim zTestResult As String
> > >   zTestDate = "5/4/2018"
> > >   zTestResult = Format(CDate(zTestDate), "mm/dd/yy ddd")
> > >   Debug "Test date: " & zTestDate & " Formatted: " & zTestResult
> > >   '' Result: Main.Main.9: Test date: 5/4/2018 Formatted: 05/04/18 ven
> > >
> > > Regards
> > > Gianluigi
> >
> > ------------------------------------------------------------
> > ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to