Open ruimelo73 opened 2 years ago
I coded localy, it works beutiful:
var today = new Date(); var year = today.getFullYear(); var month = today.getMonth(); var day = today.getDate(); var monthz = zeropad2(month); var dayz = zeropad2(day); value = value. replace(/_year_/g, year). replace(/_month_/g, month). replace(/_monthz_/g, monthz). replace(/_day_/g, day). replace(/_dayz_/g, dayz); // Time var hours = today.getHours(); var mins = today.getMinutes(); var secs = today.getSeconds(); var hoursz = zeropad2(hours); var minsz = zeropad2(mins); var secsz = zeropad2(secs); value = value. replace(/_hours_/g, hours). replace(/_mins_/g, mins). replace(/_secs_/g, secs). replace(/_hoursz_/g, hoursz). replace(/_minsz_/g, minsz). replace(/_secsz_/g, secsz); // plus 5 minutes // did not add seconds because i did not need it var hoursp5m = hours; var minsp5m = mins+5; if (minsp5m > 59) { minsp5m = minsp5m-60; if (hoursp5m >= 23) { hoursp5m = 0; } } var hoursp5mz = zeropad2(hoursp5m); var minsp5mz = zeropad2(minsp5m); value = value. replace(/_hoursp5m_/g, hoursp5m). replace(/_minsp5m_/g, minsp5m). replace(/_hoursp5mz_/g, hoursp5mz). replace(/_minsp5mz_/g, minsp5mz);
and:
function zeropad2(v) { var str = v.toString(); if (v < 10) { str = '0'+str; } return str; }
I don't work with git, so if any one could do the update, thanks!
Can you please add more reserved words (like _url_)?
Date and time would be very useful, I suggest:
This kind of reserve words will avoid the issues of date and time delimiters and formats,
Day of week or the month name would be nice also but that will require more code.
Thank you.