How to get system time & date?

Started by
4 comments, last by swiftcoder 8 years, 9 months ago

SDL 2.0

Strangely I was unable to google it, how to get a system time & date?

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

Advertisement

SDL doesn't have functionality for retrieving the system time and date. It deals solely in 'wall time' - i.e. the absolute time elapsed since the program started (which is generally all you need to run games/simulations).

You'll need to use platform-specific functions (or a 3rd-party library) to obtain calendar date and time information.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]


You'll need to use platform-specific functions (or a 3rd-party library) to obtain calendar date and time information.
Sigh... Can you recommend something light weight? Preferably crossplatform (if not then Windows) and something that's at least remotely similar to SDL interface wise.

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

time.h and gettime ?

LOL, forgot to check if it's not available in the standard C libs (strangely I never needed it before) and assumed it must be something sophisticated. OK, solved, thanks.

Stellar Monarch (4X, turn based, released): GDN forum topic - Twitter - Facebook - YouTube

Hah. I too am so used to strict localisation requirements that I never thought to check for standard C library functions for that.

Previously I've usually end up mucking around with ICU to achieve robust date formatting in every locale under the sun..

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement