Is there a way to create a /command similar to the /date command? I track my blood pressure and other things and write down the time at which I take those readings so it would be handy if instead of having to look at my watch I could just type / time. Or is this something that already exists and I have just missed it?
This actually brings up another thing, I have noticed that all timestamps are GMT. How can I go about making timestamps local time?
Yes, you can create a snippet and the body of that snippet can contain any template expression including things like {{today}}
As to the time zone. Itâs using UTC and this cannot currently be changed. Unless youâre willing to write some Space Script which would allow you to format dates however you like. There may be some examples of how to do this floating around in the Tricks & Techniques category.
Thank you. I found the time template expression, and much like today, itâs {{time}}. Now my question is how can I manipulate that to adjust to the America/Chicago time zone?
Hey, can you see if this works for you? You need to paste the space-script block anywhere in your space, and run the âSystem: Reloadâ command.
```space-script
silverbullet.registerFunction({name: "texasTime"}, (dateUTC, timeUTC) => {
const instant = Temporal.Instant.from(`${dateUTC} ${timeUTC}Z`); // we say it's UTC with the Z prefix
const zonedDateTime = instant.toZonedDateTimeISO('UTC'); // change the object type to allow time zone operations
const localTime = zonedDateTime.withTimeZone('America/Chicago'); // get the same moment but with specific time zone
return localTime.toPlainTime().toString(); // format the way you like, here HH:MM:SS
});
```
It didnât have leading zeros anywhere, should work properly now (I edited my original post for clarity).
The Space Script is indeed JavaScript, and Template Language is purpose-made for SilverBullet, but meant to be similar to whatâs out there. All of that is documented on silverbullet.md, once you know the name of what youâre looking for