Re: [Gambas-user] Format function changes date value

2018-05-19 Thread George
Tobi,

Thanks for the pointer to that thread.  I had tried searching the message
archives, but I probably didn't find it since I was looking for bugs
related to the Format function.

I did try changing CDate(...) to Date(...), but it didn't change my
results.  I had also tried an implicit conversion, but again I get the same
results.

What's important for me to know is that the current behavior is considered
correct, so I can allow for it in my code.  I was initially hesitant to
kludge a fix, only to have it broken again by a subsequent Gambas fix, but
it doesn't appear that will be a problem.

Thank you!

-George


On Sat, May 19, 2018 at 1:52 PM, Tobias Boege <tabo...@gmail.com> wrote:

> On Sat, 19 May 2018, George wrote:
> > > 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.
> >
>
> This has been discussed multiple times recently, the last time was [1].
> So let me elaborate on T Lee's answer a bit. The official statement is
> that the previous behaviour was a bug which was unfortunately not
> discovered sooner. As of Gambas 3.11, you should remember that CStr()
> and CDate(), being low-level conversions, assume UTC, i.e. they convert
> the date "literally" (without any offset) to a date and a time integer,
> which is the internal representation of a Date in Gambas.
>
> The higher-level Str(), Val(), Format() and Date() functions take the
> current locale into account. Mixing CDate() with Format() is almost always
> a bug, as one honours the local timezone and the other doesn't. CDate()
> produces a Date object which is 05/04/18 00:00 UTC but when you format
> it using Format$(), you get a string representing the same point in time
> relative to your current timezone. I'm in GMT+0200 these days so I get:
>
>   Test date: 5/4/2018 Formatted: 05/04/18 02:00 Fri
>
> Removing the "C" from the invocation of CDate(), you chain locale-aware
> functions only and get the desired result:
>
>   Test date: 5/4/2018 Formatted: 05/04/18 00:00 Fri
>
> That five minute offset you mention is indeed weird, though, and I have
> no explanation for that.
>
> Regards,
> Tobi
>
> [1] https://lists.gambas-basic.org/pipermail/user/2018-May/064153.html
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> 
> --
> 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


Re: [Gambas-user] Format function changes date value

2018-05-19 Thread George
I noticed a post from Benoît in another thread that this mailing list has
been deprecated, so I'm going to repost this in u...@lists.gambas-basic.org



On Sat, May 19, 2018 at 1:20 PM, George <gam...@geodosch.com> wrote:

> > 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


Re: [Gambas-user] Format function changes date value

2018-05-19 Thread George
> 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  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 :
>
> > 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


Re: [Gambas-user] Format function changes date value

2018-05-19 Thread George
I'm using the repository '
http://ppa.launchpad.net/gambas-team/gambas3/ubuntu'

Is there something that's more up-to-date?

On Sat, May 19, 2018 at 9:08 AM, Gianluigi <bagone...@gmail.com> 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
>
> 2018-05-19 14:54 GMT+02:00 George <gam...@geodosch.com>:
>
> > When using the Format function to format a date, the date gets offset by
> 1
> > day.  Here's an example:
> >
> >   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: Test date: 5/4/2018 Formatted: 05/03/18 Thu
> >
> > This seems to have started since the last update was applied.
> > 
> > --
> > 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


[Gambas-user] Format function changes date value

2018-05-19 Thread George
When using the Format function to format a date, the date gets offset by 1
day.  Here's an example:

  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: Test date: 5/4/2018 Formatted: 05/03/18 Thu

This seems to have started since the last update was applied.
--
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


[Gambas-user] BUG: Textlabel contents not displaying when value changes from

2010-12-09 Thread George
I'm using a Textlabel with Transparent = True.  This displays a
numeric value that can change while the program is being used.  If the
value is zero, it displays nothing (.text = ).

The problem is that if the control has no .text value, and is then
given one, it does not display.  If the value changes (e.g. from 1
to 2), the change is reflected.  I tried changing the code so that
it sets the text value to   (space) instead of , but that did not
help.  If I set Transparent = False it works correctly.  The textlabel
is over a picturebox, but that is not the problem; if I move it to
another part of the form it has the same behavior.  I also tried
performing a .Raise after updating the value, but that did not help.

What I ended-up doing in my code was to always load a value, even if
zero, and set the .Visible property based on whether or not it was
zero.  This solved my issue, but I wanted to report the bug.  I'm
running version 2.22

-George

--
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] BUG: Problem with DateAdd function

2010-12-08 Thread George
On Sun, Dec 5, 2010 at 6:31 AM, EA7DFH ea7...@ea7dfh.com wrote:
 El 05/12/10 01:16, Benoît Minisini escribió:

 But then why am I getting the 'invalid date' error in 2.22?  And more
 importantly, what do I need to do to correct it?


 That is the question!

 Check first that you really have Gambas 2.22 installed, and that you run it.
 To do that, run gbx2 -V in a terminal. You will get the interpreter 
 version.

 Regards,


 Also, make sure you did uninstalled previous versions of Gambas2. If I
 recall well, Gambas2 2.13 were installed in your system previously.

 Since the install locations of Gambas is different whether you install
 it from repositories or manually compiled (/usr/bin and /usr/local/bin
 respectively) may be you still have both of them in your system, with
 unpredictable behaviors.

 Regards,

 --
 Jesus, EA7DFH


Jesus,

Thanks!  You were right.  I'd installed 2.22 over my previous
installation... or so I thought.  So I removed everything and
reinstalled 2.22, and I'm in business.  It took me a few tries to get
everything working again, but it's up and running, and I'm no longer
getting the error on the date calculation.

Thanks to you and Benoît for you help  quick replies.

-George

--
This SF Dev2Dev email is sponsored by:

___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] BUG: Problem with DateAdd function

2010-12-04 Thread George
2010/2/13 Benoît Minisini gam...@users.sourceforge.net:
 I've run into a strange problem with the DateAdd function, when trying
 to subtract from the current date by months.

 I initially hit the problem with the following (values are hard-coded
 for clarity):
 DateAdd(cdate(2/13/2010),gb.month,-37)

 It seems that any combination of Date and Interval that results in a
 date of January 2007 causes an Invalid Date error.  For example, the
 following are all invalid:
 DateAdd(cdate(1/13/2010),gb.month,-36)
 DateAdd(cdate(2/28/2010),gb.month,-37)
 DateAdd(cdate(3/13/2010),gb.month,-38)

 Changing the starting date or the number of intervals so as to have a
 date that falls outside the month of January 2007 works okay.  It also
 works okay using periods of Year or Week that fall into those dates.

 ===

 System information:

 Gambas Version 2.13
 Components in project: gb.db, gb.db.form, gb.form, gb.gui, gb.settings,
 gb.vb

 OS: Ubuntu 9.10 Karmic Koala; Kernel 2.6.31-19-generic-pae
 GNOME 2.28.1

 Hardware: Intel Core 2 Duo processor (E8400)


 The bug has been fixed in revision #2697.

 Regards,

 --
 Benoît Minisini


This is a reply to and old post, but I'd gone off onto other projects,
and am just revisiting this...

I am currently running version 2.22.0 and am still getting the error
described above.  If the bug had been fixed in an earlier version, it
seems to have crept back in.

My Ubuntu version is currently 10.04 LTS (Lucid Lynx)

Thanks,

-George

--
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] BUG: Problem with DateAdd function

2010-12-04 Thread George
2010/12/4 Benoît Minisini gam...@users.sourceforge.net:
 
  Gambas 2.19/64 Suse11.3 locale Hong Kong:
 
  PRINT DateAdd(CDate(2/13/2010), gb.month, -36)
  PRINT DateAdd(CDate(3/28/2010), gb.month, -37)
  PRINT DateAdd(CDate(4/13/2010), gb.month, -38)
  produces
  13/02/07
  28/02/07
  13/02/07
 
  whereas
  PRINT DateAdd(CDate(1/13/2010), gb.month, -36)
  PRINT DateAdd(CDate(2/28/2010), gb.month, -37)
  PRINT DateAdd(CDate(3/13/2010), gb.month, -38)
  all produce an invalid date error.
 
  Regards
  Werner

 Forgot to mention it works in Gambas3 version 3293.


 All that is normal, as the bug has been fixed in 2.20!

 Regards,

 --
 Benoît Minisini


But then why am I getting the 'invalid date' error in 2.22?  And more
importantly, what do I need to do to correct it?

--
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user


Re: [Gambas-user] BUG: Problem with DateAdd function

2010-02-13 Thread George
Benoît,

Thanks for the quick response.  I had thought my Gambas was
up-to-date, but apparently the repository I was using is not current.
At least I'm aware of that now.

Thank you,

-George

2010/2/13 Benoît Minisini gam...@users.sourceforge.net:

 The bug has been fixed in revision #2697.

 Regards,

 --
 Benoît Minisini

 --
 SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
 Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
 http://p.sf.net/sfu/solaris-dev2dev
 ___
 Gambas-user mailing list
 Gambas-user@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/gambas-user


--
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
___
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user