Code Monkey home page Code Monkey logo

Comments (15)

Prayuga avatar Prayuga commented on August 16, 2024 6

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?

from fulfillment-bike-shop-nodejs.

DennisvdPluijm avatar DennisvdPluijm commented on August 16, 2024 5

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));

from fulfillment-bike-shop-nodejs.

unbanksytv avatar unbanksytv commented on August 16, 2024

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

from fulfillment-bike-shop-nodejs.

JohnnyB95 avatar JohnnyB95 commented on August 16, 2024

yes, how do we solve it?

from fulfillment-bike-shop-nodejs.

JohnnyB95 avatar JohnnyB95 commented on August 16, 2024

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?

from fulfillment-bike-shop-nodejs.

lupeh-dcu avatar lupeh-dcu commented on August 16, 2024

Hey guys, could anyone solve the problem above?

from fulfillment-bike-shop-nodejs.

Tirth27 avatar Tirth27 commented on August 16, 2024

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

from fulfillment-bike-shop-nodejs.

naimishranderi avatar naimishranderi commented on August 16, 2024

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

from fulfillment-bike-shop-nodejs.

jackson-zhipeng-chang avatar jackson-zhipeng-chang commented on August 16, 2024

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!

from fulfillment-bike-shop-nodejs.

Smarto-Dev avatar Smarto-Dev commented on August 16, 2024

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

from fulfillment-bike-shop-nodejs.

jackson-zhipeng-chang avatar jackson-zhipeng-chang commented on August 16, 2024

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

from fulfillment-bike-shop-nodejs.

borasuyog avatar borasuyog commented on August 16, 2024

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

from fulfillment-bike-shop-nodejs.

vidushi-agarwal avatar vidushi-agarwal commented on August 16, 2024

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.

from fulfillment-bike-shop-nodejs.

icm92 avatar icm92 commented on August 16, 2024

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.

from fulfillment-bike-shop-nodejs.

mdfarooq0815 avatar mdfarooq0815 commented on August 16, 2024

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.

from fulfillment-bike-shop-nodejs.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.