Date and time function

  1. Describe your reason for requesting this feature. What problems are you running into?

I'd like players to be able to use my games fish tank as a clock. So displaying the time and date would be great.

  1. How would this request improve your experience with using Pulp?

Would allow for date based game play.

  1. Include any other details you have relating to this request.

No rush.


I was just going to post this request, seconded!

1 Like

The datetime variable was just added. I’ll copy the docs here too:

The read-only datetime variable has the following members reflecting the current time:

  • year: 1900-10,000
  • year99: 0-99
  • month: 1-12
  • day: 1-31
  • weekday: 0-6
  • hour: 0-23
  • hour12: 1-12
  • minute: 0-59
  • second: 0-59
  • ampm: "am" or "pm"

We also just added basic left and right string padding. Formatting a clock for example could look like this:

label "[{2, :datetime.hour12}:{2,0:datetime.minute}{datetime.ampm}]" at x,y

Which would render something like:

[ 9:05pm]

(The square brackets are only present so you can see the space that is padding the hour.)


Thanks, perfect - and more than I hoped for. Might be good to add your example around formatting into the docs as well?

Good call! It’s already documented under the say function with the other string formatting stuff. I think that’s a hold over from when say was our only function that displayed text. It probably deserves its own section at this point.

Edit: and now it does! The new String formatting section of the PulpScript docs.

Just realised that the PlayDate didn't have a date function! :smiley: It does now!

To be fair, the Playdate does, it’s Pulp specifically that didn’t :playdate_wink: