[fpc-pascal] Converting from seconds to TTime: easiest way?

OBones obones at free.fr
Wed Jun 20 11:49:03 CEST 2012


Reinier Olislagers wrote:
> Morning list,
>
> I'm trying to convert a large number of seconds to a TTime.
>
> To my surprise - without a Delphi background ;) - EncodeTime only takes
> up to 59 seconds... ;)
> Same for EncodeTimeInterval

Considering that TTime is a float where the fractional part is the part 
of a day, I would do it like this:

MyTTime := HugeNumberOfSecondsInteger / (24 * 60 * 60);

There might even be a constant somewhere called SecondsPerDay that would 
save you the writing of the denominator.



More information about the fpc-pascal mailing list