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:
parent
29c2344622
commit
3bd03f0d99
1 changed files with 11 additions and 0 deletions
11
src/index.ts
11
src/index.ts
|
@ -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()}`
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue