1
0
Fork 0
mirror of https://github.com/MillironX/docker-names.git synced 2024-12-22 09:58:16 +00:00

Add date optional function

This commit is contained in:
MillironX 2021-07-20 11:13:43 -05:00
parent 29c2344622
commit 3bd03f0d99
Signed by: millironx
GPG key ID: 139C07724802BC5D

View file

@ -866,3 +866,14 @@ export function generateName(): string {
export function generateNameWithNumber() {
return `${generateName()}_${Math.floor(Math.random() * 6) + 1}`
}
/**
* Generates a name prepended by today's date in the format YYYYMMDD
* @returns {string}
*/
export function generateNameWithDate() {
var today = new Date();
today.setMinutes(today.getMinutes() - today.getTimezoneOffset());
const todayText = today.toISOString().slice(0,10).replace(/-/g,"");
return `${todayText}_${generateName()}`
}