[Lazarus] Alternative to getTime() of JavaScript

Flávio Etrusco flavio.etrusco at gmail.com
Sun Sep 25 16:51:11 CEST 2011


2011/9/24 Zaher Dirkey <parmaja at gmail.com>:
> On Sat, Sep 24, 2011 at 2:30 AM, silvioprog <silvioprog at gmail.com> wrote:
>>
>> Or...
>>
>> 2011/9/23 silvioprog <silvioprog at gmail.com>:
>> []
>> - var
>> -   Since19700101: TDateTime;
>> + const
>> +   CSince19700101 =
>> +     ((1970 { Year } - 1900) * 365.25) + ((1 { Month } - 1) * 30) + 1 {
>> Day };
>>
>> -   Result := MilliSecondsBetween(Since19700101, Now);
>> +  Result := MilliSecondsBetween(CSince19700101, Now);
>>
>> - initialization
>> -   Since19700101 := EncodeDate(1970, 1, 1);
>>
>> --
>> Silvio Clécio
>> ===============================================
>> Blog - <silvioprog.com.br>
>> Twitter - <twitter.com/silvioprog>
>> Facebook - <facebook.com/silvioprog>
>> LazSolutions - <code.google.com/p/lazsolutions>
>> LazWebSolutions - <code.google.com/p/lazwebsolutions>
>> Lazarus-BR - <groups.google.com.br/group/lazarus-br?hl=pt-BR>
>> ===============================================
>>    * Conheça nosso canal IRC sobre Lazarus: #lazarus-br *
>> ===============================================
>
>
> What about
> Result := Trunc(Now * MSecsPerDay);
>
> Zaher Dirkey
>
> --

Different from most languages, that base the date on 1899-12-30,
javascript date is based on 1970-1-1.

-Flávio




More information about the Lazarus mailing list