Date and Time API?

The RetroNET NABU-LIB z88dk C Library for creating games and software.
Post Reply
User avatar
AGMS
Posts: 12
Joined: Tue Feb 20, 2024 9:56 pm

Date and Time API?

Post by AGMS »

I was thinking of putting in a date stamp for people getting high scores in a game, but noticed that there's no way of finding it out. CP/M 3 has date and time, but we're using 2.2 which doesn't. Also nothing in NABU-LIB. Was there something in the original NABU OS that did it? Or should it be done as a RetroNet command to the adapter to get the time stamp?

If so, please return something with 4+ digit year, month, day, hour, minute, second and time zone (taken from the computer hosting the adapter). Could be just a string. On Linux the date can take a format string and spit out everything needed. Assume the NABU side will handle localisation of month and day names. Include day of week to avoid some tricky computations. Have both the numeric time zone (so we can calculate UTC time) and time zone name (can't figure it out otherwise and need it for showing the user):

date "+%F %T %z %Z %u"
2024-04-14 19:04:01 -0400 EDT 7

And hey, then someone could write a NABU clock display, one which plays music on the hour :-)

- Alex
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: Date and Time API?

Post by DJ Sures »

Hey there - sorry I didn't see this - ProductionDave mentioned your question in Discord. I updated the IA Control library to include this ability. You can provide a format to the request so any structure can be returned.

https://github.com/DJSures/NABU-LIB/tree/main/NABULIB

Find it in the IA Control
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: Date and Time API?

Post by DJ Sures »

I should also mention the formatting for your example would be like.. "yyyy-MM-dd HH:mm:ss"
User avatar
AGMS
Posts: 12
Joined: Tue Feb 20, 2024 9:56 pm

Re: Date and Time API?

Post by AGMS »

Great, thanks! Nice to see the possible date format codes are in the comment, and there are ones for time zone and year so UTC time stamps are possible.
Post Reply