javascript - Get UTC time given TZID and local time -


i trying parse .ics file in application. application has server side java layer , client side javascript part it. using ical4j library parse it.

problem dtstart of event not in utc format sometimes. , whenever not in utc .ics file has vtimezone component parsing , getting tzid property it.

java layer send json client. in above mentioned case dtstart, dtend , tzid being sent in json.

client has convert dtstart , dtend utc using tzid. tried moment.js since not find other api can this.

moment.tz("2014-02-06 05:30", "northamerica/eastern").format() 

with moment.js below error get,

typeerror: cannot call method 'rule' of undefined 

but below code works fine,

moment.tz("2014-02-06 17:30", "america/toronto").format() 

is not possible use tzid (i.e northamerica/eastern) .ics file? there other way or js library can give me utc timezones , considering observance?

you should aware icalendar specification rfc5545 states in tzid, that:

this document not define naming convention time zone identifiers. implementers may want use naming conventions defined in existing time zone specifications such public-domain tz database [tzdb]. specification of globally unique time zone identifiers not addressed document , left future study.

so while america/toronto listed in olsson database (see here), america/eastern not explains why js library cannot recognize it.

for robust design need either convert on server side utc or have actual js class capable parse ics vtimezone component.


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -