Author Topic: Unix time  (Read 1773 times)

0 Members and 1 Guest are viewing this topic.

Offline Foggy

  • Tireless poster
  • ****
  • Posts: 806
    • View Profile
Unix time
« on: March 01, 2009, 11:37:16 AM »
I am playing around with a template idea and I am after a way to check two time values to see whether or not something has timed out.

The only way I can think of doing it is with Unix(seconds since 1970) time and taking the original value from the new value and comparing the difference to a predefined timeout value.

Is it possible to have unix time added to the time macro? or perhaps a template symbol for it?

Also after some research into the time macro I have come across the symbol %now% but cant find any explanation. What does it do/what is it for?

Offline rejetto

  • Administrator
  • Tireless poster
  • *
  • Posts: 12953
    • View Profile
Re: Unix time
« Reply #1 on: March 01, 2009, 02:36:40 PM »
%now% uses the delphi time format: it's functionally equivalent to the unix time, just numerically different.
but you can use it the same way, to calculate the difference between 2 moments.

while the unix time is integer and 1 is a second, the delphi time is real(with point) and 1 is a day.


{.set|x|%now.}

do something

{.calc|(%now% - {.^x.})/(24*60*60).} seconds passed

you can even make a user-macro yourself to convert between the 2 formats.
http://www.delphifaq.com/faq/f91.shtml

Offline Foggy

  • Tireless poster
  • ****
  • Posts: 806
    • View Profile
Re: Unix time
« Reply #2 on: March 02, 2009, 05:12:49 AM »
Thankyou Rejetto.

Thats exactly what I wanted to know.

Offline Fysack

  • Tireless poster
  • ****
  • Posts: 635
  • present picture
    • View Profile
    • Admin
Re: Unix time
« Reply #3 on: March 03, 2009, 11:14:27 PM »
 :-* :-* :-* what can i say? The world is my oyster!
GOD CAN READ YOUR MIND