Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More reserved words / replaces #72

Open
ruimelo73 opened this issue Mar 18, 2022 · 1 comment
Open

More reserved words / replaces #72

ruimelo73 opened this issue Mar 18, 2022 · 1 comment

Comments

@ruimelo73
Copy link

ruimelo73 commented Mar 18, 2022

Can you please add more reserved words (like _url_)?

Date and time would be very useful, I suggest:

  • day - current day
  • dayz - current day, zero padded
  • month - current month
  • monthz - current month, zero padded
  • year - current year, full digits
  • hour - current hour
  • houzr - current hour, zero padded
  • hourampm - current hour, am/pm format
  • ampm - am or pm mark for the current hour
  • min - current minute
  • minz - current minute, zero padded
  • sec - current second
  • secz current second, zero padded

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.

@ruimelo73
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant