Comments (4)
Seems like services including Google (🙄) incorrectly parse the start- and endtime. Our service currently runs in a UTC+2 zone and all dates are in said format. After converting them to UTC google still adds 2 hours eventually to “compensate for the user’s timezone”. I’ll look into implementing the TimeZone Identifier to properly handle this.
from ics.
I find it easiest to create the date in local timezone using something like moment-timezone, convert it to UTC and then use the startInputType parameter e.g.
const ics = require('ics');
const moment = require('moment-timezone');
const event = {
start: moment.tz("2013-11-18 22:30", "Asia/Taipei").utc().format('YYYY-M-D-H-m').split("-").map(val => parseInt(val)),
startInputType: 'utc',
duration: { hours: 1, minutes: 0 },
title: 'My timezone event',
}
const { error, value } = ics.createEvent(event);
console.log(value);
This outputs:
_
BEGIN:VCALENDAR
VERSION:2.0
CALSCALE:GREGORIAN
PRODID:adamgibbons/ics
METHOD:PUBLISH
X-PUBLISHED-TTL:PT1H
BEGIN:VEVENT
UID:VVE_R4SY-k9OID55TkGZc
SUMMARY:My timezone event
DTSTAMP:20210827T172400Z
DTSTART:20131118T143000Z
DURATION:PT1H
END:VEVENT
END:VCALENDAR
_
As you can see, the DTSTART entry ends with Z to indicate it is in UTC / Zulu time, which makes it explicit exactly when the event starts. Client software will then typically convert this back to the user's local timezone before it is displayed.
from ics.
startInputType, endInputType will default to local and startOutputType, endOutputType will default to utc.
So, you could just provide the start and end parameters which would be assumed to be in the timezone set in the local environment and they would be converted to UTC/Zulu time automatically for you for display in the output.
I typically fetch stuff from backend data sources for processing in Lambda functions etc so I usually need to be explicit about what zone the data is defined in and regularly can't be sure where it will be executed. If you are, for example, running this in a browser, and accepting a user input it would likely be better to use the default behaviour. Clients consuming the feed should nearly always understand the Zulu format.
from ics.
This clears up my confusion, thanks for the quick response.
from ics.
Related Issues (20)
- Which parameter is being used to update existing event in calendar? HOT 3
- How to change the PRODID?
- Type issue for organizer attribute HOT 2
- Documentation does not cover using this package Client Side
- Calendar Side Panel in OS X Outlook?
- Callbacks and errors HOT 1
- Calendar Notifications/Alarms Not Working
- Separate calendar options from event options
- Handle organizer names with special characters correctly HOT 1
- Adding long descriptions to ICS file causes email to get lost on Outlook
- Unicode emails not passing validation check
- Faulty trigger when alert `before` is set to false.
- PARTSTAT = Accepted (and others) not working in Outlook
- Support cloudflare worker environment
- When the title contains emojis, it is unable to generate a correct summary
- Add REFRESH-INTERVAL
- Trigger is encoded twice HOT 2
- Client specific attribute X-GOOGLE-CONFERENCE HOT 1
- Allow DTSTAMP to be set like any other event attribute
- Issues with runes2 import HOT 7
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 ics.