Skip to content

Commit 6460ad8

Browse files
committed
Add "shortmonth" date option and fix existing month/date variables
- Adjust 0-based month values & use day-of-month for date - Adjust documentation - Fixes #1987 Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
1 parent d83e15c commit 6460ad8

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

document/_java.templateVariables.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Below are the predefined variables you could use in the template settings such a
99
- `${time}` - current system time
1010
- `${year}` - current year
1111
- `${month}` - current month
12+
- `${shortmonth}` - short form representation of current month
1213
- `${day}` - current day of the month
1314
- `${hour}` - current hour
1415
- `${minute}` - current minute

src/fileEventHandler.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ async function handleNewJavaFiles(e: FileCreateEvent) {
6767
package_name: "",
6868
type_name: typeName,
6969
user: userInfo().username,
70-
date: date.toLocaleDateString(),
70+
date: date.toLocaleDateString(undefined, {month: "short", day: "2-digit", year: "numeric"}),
7171
time: date.toLocaleTimeString(),
7272
year: date.getFullYear(),
73-
month: formatNumber(date.getMonth()),
74-
day: formatNumber(date.getDay()),
73+
month: formatNumber(date.getMonth() + 1),
74+
shortmonth: date.toLocaleDateString(undefined, {month: "short"}),
75+
day: formatNumber(date.getDate()),
7576
hour: formatNumber(date.getHours()),
7677
minute: formatNumber(date.getMinutes()),
7778
};

0 commit comments

Comments
 (0)