Comments (15)
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.
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.
Congratz Dennis for spotting the problem, how do we solve it?
from fulfillment-bike-shop-nodejs.
yes, how do we solve it?
from fulfillment-bike-shop-nodejs.
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.
Hey guys, could anyone solve the problem above?
from fulfillment-bike-shop-nodejs.
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.
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.
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.
@Zhipeng-Chang still the same error it says "Invalid date"
from fulfillment-bike-shop-nodejs.
@Smarto-Dev what is the error message in your firebase console?
from fulfillment-bike-shop-nodejs.
getting the issue of " sorry we're booked " every time. but no issue with date n time
from fulfillment-bike-shop-nodejs.
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.
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.
So here is the soln:
Below is the code given in the templateconst 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)
- Invalid Date HOT 31
- No appointment created in google calendar HOT 28
- Error : Initializing firebase-admin may fail HOT 1
- "TypeError: Cannot read property 'split' of undefined at convertTimestampToDate" and other such annoyances
- Appointment is not showing on my Calendaer
- Error creating agent
- Invalid date
- TypeError: Cannot read property 'source' of undefined HOT 5
- No appointment created! HOT 10
- Error in creating agent HOT 2
- Issue with Calender HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fulfillment-bike-shop-nodejs.