Comments (3)
Hi @MarsZone,
When you provide a string date to JavaScript in ISO 8601 form (yyyy-mm-dd
), JavaScript interprets it as midnight UTC. It then converts it to the local time zone of the browser, and the calendar uses the local year, month, and day of that date(ignoring the time and time zone) for display.
So, when you use 2017-12-28
, the calendar component doesn't necessarily see December 28, it sees the 27th, 28th, or 29th, depending where the user is located, and also sees a time component that resulted from the time zone conversion (which it ignores).
Because of this, dates should be provided as Date objects (e.g., new Date(2017,11,27)
for December 27--be sure to use a 0-based month).
One thing I think I'd like to do is change the component to not let JavaScript convert strings to dates automatically, and to instead do its own conversion when startDate
or endDate
are provided in a simplified ISO string form (basically modifying the dateOnly
method and using map()
along with filter()
in getWeekEvents()
to convert the dates once for each event). I think that will be necessary if we're going to support events times in the future (which I'd like to do).
from vue-simple-calendar.
See this SO answer for more details on the problems of using strings for dates:
https://stackoverflow.com/questions/33908299/javascript-parse-a-string-to-date-as-local-time-zone
from vue-simple-calendar.
Very useful. I got it.
I just use new Date(2017,11,27) give the date objects to startdate.
It works fine and you may provide the options(eg. like different date format) to chose if convert to UTC time or not?
from vue-simple-calendar.
Related Issues (20)
- Bug when using item specific classes HOT 6
- do we support drag in batch? HOT 1
- delete this
- tooltip doesn't work HOT 2
- Misaligned row in demo HOT 4
- missing export in package.json HOT 3
- Clicking & URL issues HOT 2
- How can we get the selected object from the array? HOT 1
- Error of import HOT 3
- Feature Request: Show weekdays only HOT 1
- Error when importing vue-simple-calendar/dist/style.css HOT 3
- Can't use named slots with camelCase like dayContent HOT 2
- Time slots in weekly view HOT 1
- Week Numbers are off by 1 HOT 1
- Day order HOT 2
- v7.0 error [vite:resolve] Failed to resolve entry for package "vue-simple-calendar" HOT 2
- ReadMe update HOT 1
- Month skipping in month view HOT 2
- HTML tags in `title` attribute HOT 1
- Typescript error with moduleResolution: 'bundler'
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 vue-simple-calendar.