vscode
vscode copied to clipboard
Add TIMEZONE or TIMEZONE_OFFSET to User Defined Snippet Variables
As outlined here and here, we still don't have the ability to script the creation of accurate, time-aware ISO8601 timestamps using VS Code. This is because we're missing a TIMEZONE element.
Thank you
FWIW, I agree with this request, and the name should probably be CURRENT_TZOFFSET. Its value should derive from Date.getTimezoneOffset and then be formatted accordingly, as seen as part of the larger string here.
I'd also suggest something like CURRENT_ISO8601_LOCAL_TIMESTAMP (built as shown in the prior link) and CURRENT_ISO8601_UTC_TIMESTAMP (which can be obtained directly from Date.toISOString)
Looks like the right place to add it would be here: https://github.com/microsoft/vscode/blob/71080eb345c19783eff945f2b047c6bf0803849a/src/vs/editor/contrib/snippet/browser/snippetVariables.ts#L259-L299
This is very similar to #129030 in making snippets more international.
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
👍🏾
Come on VS Code Community! Only 9 more upvotes to go and we can have complete timestamps in our SNIPPETS!
4 to go!
2 upvotes to go!! Lets go VS Code Community!!
This enhancement will allow you to automatically create aware timestamps instead of having to manually manage your UTC relation info.
Example:
-
Here's what you have to do today to generate an aware timstamp:
${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}T${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}-07:00- If your locale recognizes daylight saving time, you have to manually adjust the UTC relation info (the
-07:00/08:00)!
-
Here is what is proposed:
${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}T${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}${CURRENT_TZ}
Lets do this VS Code Community!
:slightly_smiling_face: This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
Nice work everyone!
Awwww man! Daylight savings time and I forgot to go into my Snippets: Configure User Snippets markdown.json file and update all the -07's to -08's! All timestamps that I've created since DST ended over the weekend are incorrect.
It will be very nice when the ${CURRENT_TZ} built-in variable is available... :)
I've open a pull request that adds a CURRENT_TIMEZONE_OFFSET variable that display the offset as +/-hh:mm. Let me know if this solves your issue.
Timezone changes are quickly approaching... seems the fix that @MonadChains proposed is blocked https://github.com/microsoft/vscode/pull/170518...
@MonadChains, thank you for addressing this request. I see the merge is blocked. Is there anything I can do to assist the ball forward?
https://github.com/microsoft/vscode/pull/170518 has been merged, this will ship with 1.78 stable and next/tomorrow's insiders
@jrieken I'm not sure what the "verification-needed" label requires, but I can tell you that adding $CURRENT_TIMEZONE_OFFSET to a global snippet in today's Insider build works as expected, at least for my time zone which is a positive offset. The variable expands to format [+|-]##:##.
For an ISO 8601 date and time timestamp:
$CURRENT_YEAR-$CURRENT_MONTH-${CURRENT_DATE}T$CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND$CURRENT_TIMEZONE_OFFSET
Result:
2023-04-25T13:37:45+02:00