I'm trying to add to a VSCode snippet the day of lockdown we are currently on (when the snippet is run).
My current snippet is:
"New Day Blog Entry Separator": {
"scope": "html, HTML",
"prefix": [
"dtn",
"ndbe"
],
"body": [
"<div id=$CURRENT_YEAR$CURRENT_MONTH$CURRENT_DATE$CURRENT_HOUR$CURRENT_MINUTE>",
"<hr>",
"<p style="color: cadetblue;">$CURRENT_DAY_NAME $CURRENT_DATE $CURRENT_MONTH_NAME $CURRENT_YEAR<br>",
"$CURRENT_HOUR:$CURRENT_MINUTE<br>",
"<abbr title="The UNIX Epoch occurred at 00:00 on 1st January 1970.">Epoch</abbr> Seconds: $CURRENT_SECONDS_UNIX</p>",
"<hr>",
"<h1>${2:Heading}</h1>",
"<p>${3:Body}</p>",
"</div>",
"<hr>"
],
"description": "Add a blog entry separator"
and gives the output:
<div id=202101051548>
<hr>
<p style="color: cadetblue;">Tuesday 05 January 2021<br>
15:48<br>
<abbr title="The UNIX Epoch occurred at 00:00 on 1st January 1970.">Epoch</abbr> Seconds: 1609861711
</p>
<hr>
<h1>Heading</h1>
<p>Body</p>
</div>
<hr>
I want it to give an intial Heading of "Day x of Lockdown 3.0".
i.e.:
<div id=202101051548>
<hr>
<p style="color: cadetblue;">Tuesday 05 January 2021<br>
15:48<br>
<abbr title="The UNIX Epoch occurred at 00:00 on 1st January 1970.">Epoch</abbr> Seconds: 1609861711
</p>
<hr>
<h1>Day X of Lockdown 3.0</h1>
<h1>Heading</h1>
<p>Body</p>
</div>
<hr>
The $CURRENT_DATE variable only returns the 2-digit date, rather than a full yyyymmdd string.
I think there must be a regex transformation on a variable that can do this, but I'm at a bit of a loss as to where to start.
I've seen that VS Code snippets use TextMate, and looking at the TM Manual on Dynamic Variables, there doesn't appear to be a good starting point.
I suppose I could work out the UNIX epoch seconds between now and the reference date?
But how do I then get that into a date format?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…