[Gambas-user] A little bit of Date Testing

Cedron Dawg cedron at exede.net
Wed Jun 5 15:29:41 CEST 2019


The following print statements:

        Print Now
        Print Val("4/10/1947 15:25")
        Print Date(1947, 4, 10, 15, 25, 00)
        Print Date("09/06/1972 01:45:12")
        Print CDate("09/06/1972 01:45:12")

Resulted in this output:

06/05/2019 09:13:42
04/10/1947 15:25:00
04/10/1947 15:25:00
09/05/1972 00:00:00
09/05/1972 21:45:12


The following syntax lines (extracted from context):

        theCreateRS!SomeDate = Now
        theCreateRS!SomeDate = Val("4/10/1947 15:25")
        theCreateRS!SomeDate = Date(1947, 4, 10, 15, 25, 00)
        theCreateRS!SomeDate = Date("09/06/1972 01:45:12")
        theCreateRS!SomeDate = CDate("09/06/1972 01:45:12")

Resulted in these SQLite values:

2019-06-05 09:13:41.956
1947-04-10 15:25:00
1947-04-10 15:25:00
1972-09-05 00:00:00
1972-09-05 21:45:12

So the date handling is consistent between printing and DB insertion.  This example also shows the dual nature of the Date() function.  First use, as date construction, it keeps the time and the output date matches the input date.  Second, as the Date part extraction, it strips the time away, and the output date does not match the intput date.

Describing Local vs UTC becomes confusing.  I developed a little clock "screen saver" as a visualization tool for myself.  You can find it here:

https://forum.gambas.one/viewtopic.php?f=4&t=720

Hope this helps.

Ced



More information about the User mailing list