Simplified timestampedFilename to use formatDate
This commit is contained in:
parent
5b9e0714ce
commit
cd5741d6ab
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/utils",
|
"name": "@ztimson/utils",
|
||||||
"version": "0.23.13",
|
"version": "0.23.14",
|
||||||
"description": "Utility library",
|
"description": "Utility library",
|
||||||
"author": "Zak Timson",
|
"author": "Zak Timson",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import {makeArray} from './array.ts';
|
import {makeArray} from './array.ts';
|
||||||
import {JSONAttemptParse} from './objects.ts';
|
import {JSONAttemptParse} from './objects.ts';
|
||||||
import {PromiseProgress} from './promise-progress';
|
import {PromiseProgress} from './promise-progress';
|
||||||
|
import {formatDate} from './time.ts';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Download blob as a file
|
* Download blob as a file
|
||||||
@ -76,7 +77,7 @@ export function fileText(file: any): Promise<string | null> {
|
|||||||
*/
|
*/
|
||||||
export function timestampFilename(name?: string, date: Date | number | string = new Date()) {
|
export function timestampFilename(name?: string, date: Date | number | string = new Date()) {
|
||||||
if(typeof date == 'number' || typeof date == 'string') date = new Date(date);
|
if(typeof date == 'number' || typeof date == 'string') date = new Date(date);
|
||||||
const timestamp = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}_${date.getHours().toString().padStart(2, '0')}-${date.getMinutes().toString().padStart(2, '0')}-${date.getSeconds().toString().padStart(2, '0')}`;
|
const timestamp = formatDate('YYYY-MM-DD_HH:mm:ss', date);
|
||||||
return name ? name.replace('{{TIMESTAMP}}', timestamp) : timestamp;
|
return name ? name.replace('{{TIMESTAMP}}', timestamp) : timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user