Clock_for_Choicescript

Clock_for_Choicescript

now available on : GitHub

A module for creating date, time and unix stamps, easily add or subtract dates to travel in time, and then include it into your text! Written entirely in ChoiceScript, it has a flexible set up to accommodate a variety of calendar or time systems, with custom formatting.

Features

  • Setup your own calendrical and time systems.
  • Create your own custom datetime stamp formats.
  • Use relative time travel (add or subtract datetimes to adjust the clock).
  • Includes math operations: floor and ceil (works for negative values too).
  • Includes number to ordinal converter : (1) → (1st).
  • Flexible and logical to use, with a wide range of options for ease of use.

Introduction

Full instructions are in the README.md file on GitHub.

To set the date and time use *gosub_scene clock set_current “07/12/2025 16:55:12”

Then to use it in your text use The date is ${stamp_date} and the time is ${stamp_time}

You can change the date stamp formatting using *gosub_scene clock set_format_date “www mmm ddd yyyy” so the above sentence would now output The date is Sun Dec 12th 2025 and the time is 16:55:12

Change the time stamp formatting using *gosub_scene clock set_format_time “hhhh-mm-ss” so the above sentence would now output `The date is Sun Dec 12th 2025 and the time is 04-55-12 pm

You can also get a pseudo-unix stamp The pseudo-unix time is ${stamp_unix} which will output The pseudo-unix time is 1765126512

Travel in relative time, whatever the current date, if you want to change it by nearly 3 weeks use *gosub_scene clock travel “21D-10h” the output for the above example would now be The date is Sun Dec 28th 2025 and the time is 06-55-12 am

You can also output just part of any time by referencing the variable directly such as It was ${hour} o’ clock...

The ordinal routine also lets you easily convert unknown numbers into ordinal numbers at runtime, such as:

*temp place 1
*rand place 1 10
*gosub_scene clock ordinal place
You placed ${returnVal} in the race!
--> Outputs --> You placed 3rd in the race!

Feedback

I have only just published this module, and whilst I have tested it thoroughly, there may be edge cases or bugs I have missed, so if you notice any please report them!

Any comments or suggestions, (including on documentation and user experience) please comment below, or see also the discussions or issues tab on GitHub.

I hope you find this useful!

4 Likes

This is neat – nice going!

1 Like