Author Topic: A (simpler) timestamp function  (Read 3903 times)

0 Members and 1 Guest are viewing this topic.

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
A (simpler) timestamp function
« on: August 30, 2019, 09:07:32 am »
Steve has a function here that generates a timestamp based on the Unix timestamp, seconds since 1/1/1970. However, it's rather... complex, and doesn't take into account the silliness that is daylight saving.

Here's a simpler one. Works on both Windows & Linux, returns the Unix timestamp.

Code: [Select]
DECLARE LIBRARY
    FUNCTION time& (BYVAL null&)
END DECLARE

PRINT timestamp

FUNCTION timestamp&
    timestamp& = time&(0)
END FUNCTION
« Last Edit: August 30, 2019, 09:08:34 am by luke »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: A (simpler) timestamp function
« Reply #1 on: August 30, 2019, 09:31:40 am »
Hi Luke,

Can you do different date+time conversions to seconds?

Offline luke

  • Administrator
  • Seasoned Forum Regular
  • Posts: 324
    • View Profile
Re: A (simpler) timestamp function
« Reply #2 on: August 30, 2019, 09:39:19 am »
If you want to map these to actual datetimes, go use Steve's function.

This is for if you need a reliable counter like TIMER that doesn't suffer from wrap-around, daylight saving, timezones etc.