我创建的DateTime对象与DateTime.Now之间的区别 [英] Difference between a DateTime object I create and DateTime.Now

查看:245
本文介绍了我创建的DateTime对象与DateTime.Now之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Exchange 2007 API查询特定用户的日历可用性.我的示例代码产生了以下异常:

I'm trying to use the Exchange 2007 API to query calendar availability for a specific user. My sample code is producing the following exception:

为FreeBusyViewOptions.TimeWindow指定的持续时间为 无效.

The time duration specified for FreeBusyViewOptions.TimeWindow is invalid.

这是示例代码:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

service.AutodiscoverUrl("email@domain.com");

DateTime startTime = new DateTime(2012, 1, 6, 7, 0, 0);

TimeWindow tw = new TimeWindow(startTime, startTime.AddHours(8));

GetUserAvailabilityResults result = service.GetUserAvailability(new List<AttendeeInfo> { new AttendeeInfo("email@domain.com") }, tw, AvailabilityData.FreeBusyAndSuggestions);

更奇怪的是,如果我将startTime分配替换为以下内容,它将起作用:

The wierd thing is, if I replace my startTime assignment with the following it works:

DateTime startTime = DateTime.Now;

我创建的DateTime对象与DateTime.Now生成的对象之间有什么区别?我在调试时已对它们进行了详细检查,没有发现任何区别.

What's the difference between the DateTime object I created and the object produced by DateTime.Now. I've examined them in detail while debugging and can't find a difference.

有什么想法吗?

推荐答案

与任何DateTime操作相反,这实际上是GetUserAvailability方法中的问题.

This actually appears to be an issue in the GetUserAvailability method as opposed to any DateTime manipulation.

根据 MSDN文档:

GetUserAvailability(Generic,TimeWindow,AvailabilityData,AvailabilityOptions)方法仅支持至少24小时长且始于12:00 a.m的时间段.要将方法的结果限制为较短的时间,必须在客户端上过滤结果.

The GetUserAvailability(Generic ,TimeWindow,AvailabilityData,AvailabilityOptions) method supports only time periods that are a minimum of 24 hours long and that begin and end at 12:00a.m. To restrict the results of the method to a shorter time period, you must filter the results on the client.

这篇关于我创建的DateTime对象与DateTime.Now之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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