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

Use plain JavaScript instead of moment.js #3

Open
Tobi0892 opened this issue Sep 29, 2019 · 1 comment
Open

Use plain JavaScript instead of moment.js #3

Tobi0892 opened this issue Sep 29, 2019 · 1 comment

Comments

@Tobi0892
Copy link

Attached a plain javascript version without including the whole moment.js library.

I just modified the _updateTime function:

_updateTime(force = false) {
    var days = ['Sonntag','Montag','Dienstag','Mittwoch','Donnerstag','Freitag','Samstag'];
    var Digital = new Date();
    var hours = Digital.getHours();
    var minutes = Digital.getMinutes();
    var seconds = Digital.getSeconds();
    var day = Digital.getDate();
    var year = Digital.getFullYear();
    var month = Digital.getMonth() + 1;

    if (hours <= 9) {
        hours = "0" + hours;
    }
    if (minutes <= 9) {
        minutes = "0" + minutes;
    }
    if (seconds <= 9) {
        seconds = "0" + seconds;
    }
    if (day <= 9) {
        day = "0" + day;
    }
    if (month <= 9) {
        month = "0" + month;
    }

    this.time.innerHTML = hours + ":" + minutes + ":" + seconds;
    this.date.innerHTML = days[Digital.getDay()] + ", " + day + "." + month + "." + year;
  }
@kpagnat
Copy link

kpagnat commented Jul 16, 2020

Perfect, can't stand using external library !

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

2 participants