-
Notifications
You must be signed in to change notification settings - Fork 341
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
Parsing the input with respect to user timezone. #214
Comments
Since the parsing is happening server site you're going to need to have the user's timezone saved already. Once you know their timezone you should be able to use the timezoneOffset feature. |
I ran into this issue myself. I had to pass const parsedDate = chrono.parse(
req.body.inputTimeText, //input text from user such as in 10 minutes, today at 11 AM etc.
moment().utcOffset(req.user.utcTimezoneOffset) //From DB
)[0].start;
parsedDate.assign('timezoneOffset', req.user.utcTimezoneOffset);
const parsedMoment = moment(parsedDate.date())
.utcOffset(req.user.utcTimezoneOffset);
const scheduleTime = parsedMoment.toISOString();
const message = parsedMoment.calendar(); // returns Today at 11 AM |
@harshithkashyap Thanks for your solution. I think |
@harshithkashyap's solution no longer works ( |
For future reference, this solved my issue for me: #327 (comment) |
Hello, thanks for creating such an awesome API.
Presently, I am using this api for my project. I am running a node js application on heroku server.
I am facing a problem for parsing input with respect to timezone.
Suppose my user is in timezone IST(5.5) and send the time query to server "now" which is "2017-08-25T14:25:11.993662Z" according to my heroku server.
So what I want to do is parse the "now" and get the time with respect to user time zone.
Actually I am developing a Facebook chatbot and for that I am using this api.
Only thing I get to know about user is their timezone which is for India user on fb is 5.5
So how can I use this 5.5 to parse the input "now" with respect to user timezone.
Also if user send time query as "tomorrow at 5pm" then how can I get it as "2017-08-26T17:00:00.000Z" in IST
Please help.
The text was updated successfully, but these errors were encountered: