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.
How would this request improve your experience with using Pulp?
Would allow for date based game play.
Include any other details you have relating to this request.
No rush.
4 Likes
cosmicsans
(Joah Reason)
January 29, 2022, 12:38am
2
I was just going to post this request, seconded!
1 Like
shaun
(Shaun Inman)
February 11, 2022, 3:46pm
3
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.)
3 Likes
Thanks, perfect - and more than I hoped for. Might be good to add your example around formatting into the docs as well?
shaun
(Shaun Inman)
February 11, 2022, 4:13pm
5
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! It does now!
shaun
(Shaun Inman)
February 11, 2022, 4:35pm
7
To be fair, the Playdate does, it’s Pulp specifically that didn’t
2 Likes