[Gambas-user] "Strange" results from Time( ) function ?

Jussi Lahtinen jussi.lahtinen at ...626...
Fri Oct 11 14:47:22 CEST 2013


I took a look into source code and I think this is because seconds are
stored in memory as short.
And this confirms I understand correctly:

? time(0,0,32766)
09.06.06

? time(0,0,32767) <--- last good value for signed short
09.06.07

? time(0,0,32768)
14.53.52


1.
So, one simple correction is just change documentation "as integer" --> "as
short".

2.
Or do conversion from seconds to minutes (if they are over 32767) before
asserting them to;

    date.hour = PARAM->_integer.value;
    date.min = PARAM[1]._integer.value;
    date.sec = PARAM[2]._integer.value;

3.
Or change declaration of date, short --> integer.


However, I don't think I know enough about internal work of Gambas to
really make that decision.
What do you think Benoit?


Jussi


On Wed, Oct 9, 2013 at 8:28 PM, Jussi Lahtinen <jussi.lahtinen at ...626...>wrote:

> Confirmed with latest revision (5870) @ Xubuntu 13.04 64 bit.
>
> Jussi
>
>
> On Fri, Sep 13, 2013 at 8:44 PM, Ru Vuott <vuott at ...325...> wrote:
>
>> Hello,
>>
>> I tried this code:
>>
>>
>> Public Sub Form_Open()
>>
>>   Dim i As Integer
>>
>>     For i = 1 To 24
>>
>>        Print Time(0, 0, 3600 * i), 3600 * i
>>
>>     Next
>>
>> End
>>
>>
>> and here its results :
>>
>> 01:00:00        3600
>> 02:00:00        7200
>> 03:00:00        10800
>> 04:00:00        14400
>> 05:00:00        18000
>> 06:00:00        21600
>> 07:00:00        25200
>> 08:00:00        28800
>> 09:00:00        32400
>> 15:47:44        36000
>> 16:47:44        39600
>> 17:47:44        43200
>> 18:47:44        46800
>> 19:47:44        50400
>> 20:47:44        54000
>> 21:47:44        57600
>> 22:47:44        61200
>> 23:47:44        64800
>> 00:47:44        68400
>> 01:47:44        72000
>> 02:47:44        75600
>> 03:47:44        79200
>> 04:47:44        82800
>> 05:47:44        86400
>>
>>
>> ......Do not it seem to you that there is something strange in the
>> results?   :-O
>>
>> Regards
>>
>> vuott
>>
>>
>> ------------------------------------------------------------------------------
>> How ServiceNow helps IT people transform IT departments:
>> 1. Consolidate legacy IT systems to a single system of record for IT
>> 2. Standardize and globalize service processes across IT
>> 3. Implement zero-touch automation to replace manual, redundant tasks
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=51271111&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>
>



More information about the User mailing list