All files
[pithos-ms-client] / trunk / Libraries / Json40r2 / Source / Src / Newtonsoft.Json / Converters / DateTimeConverterBase.cs
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5
6 namespace Newtonsoft.Json.Converters
7 {
8   /// <summary>
9   /// Provides a base class for converting a <see cref="DateTime"/> to and from JSON.
10   /// </summary>
11   public abstract class DateTimeConverterBase : JsonConverter
12   {
13     /// <summary>
14     /// Determines whether this instance can convert the specified object type.
15     /// </summary>
16     /// <param name="objectType">Type of the object.</param>
17     /// <returns>
18     ///         <c>true</c> if this instance can convert the specified object type; otherwise, <c>false</c>.
19     /// </returns>
20     public override bool CanConvert(Type objectType)
21     {
22       if (objectType == typeof(DateTime) || objectType == typeof(DateTime?))
23         return true;
24 #if !PocketPC && !NET20
25       if (objectType == typeof(DateTimeOffset) || objectType == typeof(DateTimeOffset?))
26         return true;
27 #endif
28
29       return false;
30     }
31   }
32 }