Is it possible to use UTC Offset instead of timezone name on iCal.net?

我怕爱的太早我们不能终老 提交于 2019-12-12 17:07:46

问题


My application stores the UTC offset on users profile (-03:00, for instance) and as this page from iCal.net Wiki mentions it seems that I can only use the timezone to assign to the event: https://github.com/rianjs/ical.net/wiki/Working-with-time-zones.

Do I have any other option?


回答1:


ical.net uses NodaTime under the hood to do time zone conversions, which means you can use the Etc/GMT family of zones. Wikipedia has a nice list. In your case, you would specify a time zone of Etc/GMT-3:

const string ianaZone = "Etc/GMT-3";
var start = DateTime.Now;
var end = start.AddHours(1);

var vEvent = new Event
{
    DtStart = new CalDateTime(start, ianaZone),
    DtEnd = new CalDateTime(end, ianaZone),
};


来源:https://stackoverflow.com/questions/41331708/is-it-possible-to-use-utc-offset-instead-of-timezone-name-on-ical-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!