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

Invalid date #9

Open
kennymac3 opened this issue Oct 18, 2018 · 15 comments
Open

Invalid date #9

kennymac3 opened this issue Oct 18, 2018 · 15 comments

Comments

@kennymac3
Copy link

Hi there,

thanks for creating this template.

After i have followed all the steps, i tried the bot and after i fill up the date and time, it says " I'm sorry, there are no slots available for Invalid Date. "

Possible to assist? Thanks in advance!
Kenny

@DennisvdPluijm
Copy link

I experienced the same issue (albeit with the code version from this tutorial) and traced it down to the time zone offset. I'm in European time zone (GMT+1) and configured my agent, fulfillment and calendar to be in this time zone, rather than in the LA time zone in the code.
The parsing code in the snippet below assumes the "date" parameter to contain a "-" to split, so it only supports time zones with a negative offset.

function makeAppointment (agent) {
   // Calculate appointment start and end datetimes (end = +1hr from start)
   const dateTimeStart = new Date(Date.parse(agent.parameters.date.split('T')[0] + 'T' + agent.parameters.time.split('T')[1].split('-')[0] + timeZoneOffset));

@unbanksytv
Copy link

Congratz Dennis for spotting the problem, how do we solve it?

@JohnnyB95
Copy link

yes, how do we solve it?

@JohnnyB95
Copy link

I experienced the same issue (albeit with the code version from this tutorial) and traced it down to the time zone offset. I'm in European time zone (GMT+1) and configured my agent, fulfillment and calendar to be in this time zone, rather than in the LA time zone in the code.
The parsing code in the snippet below assumes the "date" parameter to contain a "-" to split, so it only supports time zones with a negative offset.

function makeAppointment (agent) {
   // Calculate appointment start and end datetimes (end = +1hr from start)
   const dateTimeStart = new Date(Date.parse(agent.parameters.date.split('T')[0] + 'T' + agent.parameters.time.split('T')[1].split('-')[0] + timeZoneOffset));

What do we need to modify in our code to allow for support of other timezones?

@Prayuga
Copy link

Prayuga commented Jan 31, 2019

yes, how do we solve it?

in this code : agent.parameters.time.split('T')[1].split('-')[0]
just replace '-' to your local timezone symbol
for an example, my timezone is +07:00, then i replace '-' to '+'
but the response is still

"I'm sorry, there are no slots available for February 1, 1 PM."

which is i don't have any event for that date in my google calendar
how to fix it?

@lupeh-dcu
Copy link

Hey guys, could anyone solve the problem above?

@Tirth27
Copy link

Tirth27 commented May 5, 2019

Setting proper timezone and timeZoneOffset i.e const timeZone and const timeZoneOffset works for me.
Find your timezone here:- https://www.zeitverschiebung.net/en/

@naimishranderi
Copy link

const dateTimeStart = new Date(Date.parse(agent.parameters.date.split('T')[0] + 'T' + agent.parameters.time.split('T')[1].split('-')[0] + timeZoneOffset));

Hi Dennis, I am in New Zealand time .
I changed the setting as per your suggestion but no luck. Can you please help. Thanks
Naimish

@jackson-zhipeng-chang
Copy link

Hi all! I fixed the problem by changing the code to:
const dateTimeStart = new Date(Date.parse(agent.parameters.date.split('T')[0] + 'T' + agent.parameters.time + timeZoneOffset));

I found that the agent.parameters.time always return the time in this format: '15:32:00', so there is no need to split the time with '-' or 'T', we can just combine the time with the date and timeZone offset as long as you have correct offset.

Hopefully It helps!

@Smarto-Dev
Copy link

@Zhipeng-Chang still the same error it says "Invalid date"

@jackson-zhipeng-chang
Copy link

jackson-zhipeng-chang commented Jul 4, 2019

@Smarto-Dev what is the error message in your firebase console?

@borasuyog
Copy link

getting the issue of " sorry we're booked " every time. but no issue with date n time

@vidushi-agarwal
Copy link

vidushi-agarwal commented Mar 17, 2020

So here is the soln:
Below is the code given in the template

 const timeZone = 'America/Los_Angeles'; 
 const timeZoneOffset = '-07:00'; 
 const dateTimeStart  = new Date(Date.parse(agent.parameters.date.split('T')[0] + 'T' + agent.parameters.time.split('T')[1].split('-')[0] + timeZoneOffset));

As we can see, the timezone followed is 'America/Los_Angeles', But as I live in India, changed code snippet will be:

 const timeZone = 'India/Kolkata'; 
 const timeZoneOffset = '+5:30'; 
 const dateTimeStart  = new Date(Date.parse(agent.parameters.date.split('T')[0] + 'T' + agent.parameters.time.split('T')[1].split('+')[0] + timeZoneOffset));

//check how I replaced '-' with '+' as offset for me is '+5:30' in last line

Hence find your respective timezones and do the mentioned changes.

@icm92
Copy link

icm92 commented Jul 10, 2020

See below the code that worked for me. Take as example Spain:

const timeZone = 'Europe/Madrid'
const timeZoneOffset = '+02:00'
const dateTimeStart = new Date(Date.parse(agent.parameters.date.split('T')[0] + 'T' + agent.parameters.time.split('T')[1].split('+')[0] + timeZoneOffset))

Make sure you have the time timeZoneOffset with the following format '+/-nn:nn'. I was missing the leading zero ('+02:00') in my example.

@mdfarooq0815
Copy link

So here is the soln:
Below is the code given in the template

 const timeZone = 'America/Los_Angeles'; 
 const timeZoneOffset = '-07:00'; 
 const dateTimeStart  = new Date(Date.parse(agent.parameters.date.split('T')[0] + 'T' + agent.parameters.time.split('T')[1].split('-')[0] + timeZoneOffset));

As we can see, the timezone followed is 'America/Los_Angeles', But as I live in India, changed code snippet will be:

 const timeZone = 'India/Kolkata'; 
 const timeZoneOffset = '+5:30'; 
 const dateTimeStart  = new Date(Date.parse(agent.parameters.date.split('T')[0] + 'T' + agent.parameters.time.split('T')[1].split('+')[0] + timeZoneOffset));

//check how I replaced '-' with '+' as offset for me is '+5:30' in last line

Hence find your respective timezones and do the mentioned changes.

Thanks man, worked for me.

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