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

Show how much time is left after later.js text parser applied #218

Open
sergibondarenko opened this issue Nov 27, 2017 · 1 comment
Open

Comments

@sergibondarenko
Copy link

sergibondarenko commented Nov 27, 2017

How to display what time is left after the later.js text parser applied?

For example, I want to know it before the setInterval started.

const later = require('later');

later.date.localTime();
const schedule = later.parse.text('at 12:40');

later.setInterval(() => {
    console.log('executed!');
}, schedule);

StackOverflow question.

@Grayda
Copy link

Grayda commented May 15, 2018

Looks like you've accepted an answer over at StackOverflow, but in case anyone else is reading this, I use moment.js with the fromNow() function to show, in a human readable form, how long until the next occurrence:

next = later.schedule(mySchedule).next()
timeLeft = moment(next).fromNow()
console.log(timeLeft) // 'in 20 minutes'

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