Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Time parsing functionality was unneccessarily complicated #49

Merged
merged 1 commit into from May 28, 2018
Merged

Time parsing functionality was unneccessarily complicated #49

merged 1 commit into from May 28, 2018

Conversation

Bystroushaak
Copy link
Contributor

No description provided.

@codesardine
Copy link
Collaborator

Thanks 👍

@codesardine codesardine merged commit 86ae563 into Manjaro-WebDad:master May 28, 2018
@Bystroushaak
Copy link
Contributor Author

Also is there a reason why you use setTimeout in this recursive manner and not setInterval?

@Bystroushaak Bystroushaak deleted the patch-1 branch May 28, 2018 21:30
@codesardine
Copy link
Collaborator

Yes, setTimeout only fires once, and that's all I need.

@Bystroushaak
Copy link
Contributor Author

But it is not, it is called recursively. I mean, instead of

function timeDate() {
    var today = new Date();
    document.getElementById("time").innerHTML = today.toTimeString().slice(0, 8);
    document.getElementById("date").innerHTML = today.toDateString();
    var updateTime = setTimeout("timeDate()", 200);
}

you can do

function timeDate() {
    var today = new Date();
    document.getElementById("time").innerHTML = today.toTimeString().slice(0, 8);
    document.getElementById("date").innerHTML = today.toDateString();
}
setInterval(timeDate, 200);

It should be slightly more efficient.

@codesardine
Copy link
Collaborator

Ok i see what you mean, will use setInterval instead 👍

@codesardine
Copy link
Collaborator

Now i remember why i used setTimeout recursively
setInterval(timeDate, 200); does not update the clock properly and it lags behind

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

Successfully merging this pull request may close these issues.

None yet

2 participants