从Google日历导入时,D日日历的日期有误? [英] D-Day Calendar has wrong dates when importing from google calendar?

查看:95
本文介绍了从Google日历导入时,D日日历的日期有误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是D日日历,我不确定,但是遇到了一个奇怪的问题.

I am using D-Day calendar and I am not sure but I got a weird problem.

我的代码基本上都有这个

I basically have this for my code

iCalendar iCal = iCalendar.LoadFromStream(file.InputStream);
 foreach (Event evt in iCal.Events)
                {
                   DateTime start = evt.DTStart.Date;
                   DateTime end = evt.DTEnd.Date;
                  // loop through it and get values.
                }

但是,当我从Google日历导入日历时,结束日期会弄乱我正在导入的某些内容.

Yet when I import a calendar from google calendar the end date is messed up on some of the stuff I am importing.

例如,我有这个

标题:不应显示 时间:3月21日,星期日(全天).

Title: should not show When: Sun, March 21(all day).

但是,当我将其导入时,我说开始日期是21日,而结束日期是22日,当它应该是21日时.

Yet when I import it in. I says the start date is the 21st yet the end date is the 22nd when it should be the 21st.

不确定发生了什么事情.

Not sure what is going on.

我不确定我还能给你们提供什么其他信息.

I am not really sure what other info I can give you guys.

我制作了一个cmd line应用程序,并将.ics文件放入其中.如果有人知道一个好地方,我可以上传它,你们可以明白我的意思.

I made a cmd line application and put the .ics file in it. If anyone knows a good place I can upload it and you guys can see what I mean.

这是我的cmd行输出的内容.

This is what my cmd line is outputting.

Start Date Of this Record
Some one day task 3/25/2010 12:00:00 AM
End Date of this Record 3/26/2010 12:00:00 AM


Start Date Of this Record
Test using quick create(bubble that shows up when clicked on date box) - 1 day t
ask 3/21/2010 12:00:00 AM
End Date of this Record 3/22/2010 12:00:00 AM


Start Date Of this Record
Spans 2 days 3/30/2010 12:00:00 AM
End Date of this Record 4/1/2010 12:00:00 AM

推荐答案

如果是全天活动,我相信结束时间将是第二天的00:00:00,又名12:00:00 AM.这不是您所看到的时代吗?

If it is an all day event, I believe the end time will be 00:00:00 on the next day, aka 12:00:00 AM. Is this not what you're seeing for the times?

您提供的最后一个示例确实跨越了两天(3月为31天),并且是正确的.您看到的输出与全天活动的定义息息相关.它从12:00 AM开始,到第二天12:00 AM结束.

The last example you give truly does span two days (March has 31 days), and is correct. The output you're seeing jives with the definition of an All Day Event. It begins at 12:00 AM and ends at 12:00 AM the next day.

如果您希望全天活动真正只保留在同一天,则可以执行以下检查:

If you wanted All Day events to truely stay only on the same day, you could do a check like:

if (((end - start) == TimeSpan.FromDays(1.0))
    && (start.Hour == 0 && start.Minute == 0))
{
    end = end - TimeSpan.FromSeconds(1.0); // now 23:59:59 same day as start
}

这篇关于从Google日历导入时,D日日历的日期有误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆