Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Support for real time server time updates in amTimeAgo #148

Open
MarkKerby opened this issue Jul 15, 2015 · 3 comments
Open

Support for real time server time updates in amTimeAgo #148

MarkKerby opened this issue Jul 15, 2015 · 3 comments
Assignees

Comments

@MarkKerby
Copy link

getNow() does not support a server time that is updated in real time inside the amTimeAgo directive. This causes the time since text to be incorrect as amTimeAgoConfig.serverTime drifts from localDate.

The below code implements a fix for a dynamic server time however consideration will have to be made for users relying on the current behaviour.

function getNow() {
    var now;
    if (amTimeAgoConfig.serverTime) {
        now = amTimeAgoConfig.serverTime;
    }
    else {
        now = moment();
    }
    return now;
}
@urish
Copy link
Owner

urish commented Sep 15, 2015

@MarkKerby what is the use case for that? I can't think of a case where the local time of a machine will significantly drift in comparison with the server time?

@urish urish self-assigned this Sep 15, 2015
@MarkKerby
Copy link
Author

The nature of our application means we don’t want to rely too much on the user’s system clock. So we let it perform the seconds ticking but we resynchronize it at regular intervals. This prevents, for example a user who sets their clock backwards from being shown e.g. “In 10 minutes” for something that has already happened.

We appreciate that would be an unusual thing to do but we need to avoid showing incorrect information in all cases that we can.

@yoavprat
Copy link

yoavprat commented Nov 9, 2015

how can I use this config?
am-server-time="{{serverTime}}" didn't work

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

No branches or pull requests

3 participants