diff --git a/messages/en.json b/messages/en.json index a6ed3e0..3df9e3d 100644 --- a/messages/en.json +++ b/messages/en.json @@ -206,7 +206,7 @@ "title": "Conversion", "advanced_settings": "Advanced settings", "filename_format": "File name format", - "filename_description": "This will determine the name of the file on download, not including the file extension. You can put these following templates in the format, which will be replaced with the relevant information: %name% for the original file name, %extension% for the original file extension, and %date% for a date string of when the file was converted.", + "filename_description": "This will determine the name of the file on download, not including the file extension. You can put the following templates in the format, which will be replaced with the relevant information: %name% for the original file name, %extension% for the original file extension, %datetime% for the full ISO 8601 timestamp, %date% for the date, %time% for the time, and %unix% for the unix timestamp.", "placeholder": "VERT_%name%", "default_format": "Default conversion format", "default_format_enable": "Enable", diff --git a/src/lib/types/file.svelte.ts b/src/lib/types/file.svelte.ts index f2eaccf..7113499 100644 --- a/src/lib/types/file.svelte.ts +++ b/src/lib/types/file.svelte.ts @@ -483,11 +483,18 @@ export class VertFile { const filenameFormat = settings.filenameFormat || "VERT_%name%"; const format = (name: string) => { - const date = new Date().toISOString(); + const now = new Date(); + const iso = now.toISOString(); + const date = iso.split("T")[0]; + const time = iso.split("T")[1].split(".")[0].replace(/:/g, "-"); + const unix = now.getTime().toString(); const baseName = this.file.name.replace(/\.[^/.]+$/, ""); const originalExtension = this.file.name.split(".").pop()!; return name + .replace(/%datetime%/g, iso) .replace(/%date%/g, date) + .replace(/%time%/g, time) + .replace(/%unix%/g, unix) .replace(/%name%/g, baseName) .replace(/%extension%/g, originalExtension); };