DateTime Error
Re: DateTime Error
Thanks, I should have remembered that. Honestly, it's not all that often that I move controls around the form.
Code:
Dim d As DateBox Dim s As String d = New DateBox(Me) d.Move(100, 100, 100, 20) d.Show() d.Value = CDate("01/01/2019") s = CDate("01/01/2019") d.Value = CDate(s) Print s Print d.Value Print CFloat(CDate(s)) Print CFloat(d.Value) Print CFloat(CDate(d.Value))Output:
Code: Select all
01/01/2019
12/31/2018 00:00:00
2490589
2490588.16666667
2490588.16666667
(Side note: Could you guys put one of those handy "SELECT ALL" options in the "gb" tag output?
Ced
[System]
Gambas=3.12.2
OperatingSystem=Linux
Kernel=3.13.0-24-generic
Architecture=x86_64
Distribution=Linux Mint 17 Qiana
Desktop=MATE
Theme=Gtk
Language=en_US.UTF-8
.... and carry a big stick!
- cogier
- Site Admin
- Posts: 646
- Joined: Wednesday 21st September 2016 2:22pm
- Location: Guernsey, Channel Islands
Re: DateTime Error
It works OK for me.

You can change line 10 to: -

You can change line 10 to: -
d.Value = "01/01/2019"Same result.
Re: DateTime Error
Somewhat tracing what happens in the code (shown below)
So I am a bit puzzled. I've always understood internal date representation to be Integer Date + Fraction Of Day Time.
Looks like Str and Val might be problematic.
Ced
From: gambas-master/comp/src/gb.form/.src/Date/DateBox.class
Dim t As String Dim v As Date Dim f As Float Dim w As Date v = CDate("01/01/2019") t = Format(v, "mm/dd/yyyy") f = Val(t) w = f ' Implied CDate Print v Print CFloat(v) Print CStr(v) Print Str(v) Print t Print f Print CDate(f) Print wProduces:
Code: Select all
12/31/2018 20:00:00
2490589
01/01/2019
12/31/2018 20:00:00
12/31/2018
2490588.16666667
12/31/2018 00:00:00
12/31/2018 00:00:00
Looks like Str and Val might be problematic.
Ced
From: gambas-master/comp/src/gb.form/.src/Date/DateBox.class
Private Function Value_Read() As Date Dim vVal As Variant If Not $bShowDate Then vVal = Time(Val(Format(Date(1, 1, 1), "dd/mm/yyyy") & " " & $hButtonBox.Text)) Else vVal = Val($hButtonBox.Text) Endif If vVal And If TypeOf(vVal) = gb.Date Then Return vVal End Private Sub Value_Write(Value As Date) If IsNull(Value) Then $hButtonBox.Text = GetNullDate() Else $hButtonBox.Text = Format(Value, GetDateFormat()) Endif End
Private Sub GetDateFormat() As String Dim sFormat As String If $bShowDate Then sFormat = Format(Date(3333, 11, 22), gb.ShortDate) sFormat = Replace(sFormat, "3333", "yyyy") sFormat = Replace(sFormat, "22", "dd") sFormat = Replace(sFormat, "11", "mm") Endif If $bShowTime Then sFormat &= " " & Format(Time(11, 22, 33), gb.ShortTime) sFormat = Replace(sFormat, "11", "hh") sFormat = Replace(sFormat, "22", "nn") sFormat = Replace(sFormat, "33", "ss") Endif Return LTrim(sFormat) End
.... and carry a big stick!
Re: DateTime Error
It helps to RTFM. The Str$ vs CStr is a localization issue.
http://gambaswiki.org/wiki/lang/cstr
vs
http://gambaswiki.org/wiki/lang/str
Same with val vs CDate.
So, val and str use localization, CDate and CStr do not.
Hence the observed behavior.
I have not been able to reproduce the OP's original bug.
Ced
http://gambaswiki.org/wiki/lang/cstr
vs
http://gambaswiki.org/wiki/lang/str
Same with val vs CDate.
So, val and str use localization, CDate and CStr do not.
Hence the observed behavior.
I have not been able to reproduce the OP's original bug.
Ced
.... and carry a big stick!
- Quincunxian
- Posts: 112
- Joined: Sunday 25th June 2017 12:14am
- Location: Western Australia
Re: DateTime Error
Ok that makes sense now.
Thanks to all.
I've been keeping a list of things that are either bugs(?) that need to be confirmed or a bit of a wish list.
I'll post in a new thread with a more appropriate title a bit later on.

Thanks to all.
I've been keeping a list of things that are either bugs(?) that need to be confirmed or a bit of a wish list.
I'll post in a new thread with a more appropriate title a bit later on.
Cheers - Quin.
I code therefore I am
I code therefore I am
Re: DateTime Error
This work for me:
DateBox1.Value=CDate(CDate("01/01/2019")+1)
DateBox1.Value=CDate(CDate("01/01/2019")+1)
- BruceSteers
- Posts: 390
- Joined: Thursday 23rd July 2020 5:20pm
Re: DateTime Error
It might not have 2 years ago when the post was made

Wishing well
Bruce
If at first you don't succeed , try it differently.
Bruce
If at first you don't succeed , try it differently.