/// <summary> /// Converts from date time. /// </summary> /// <param name="input">The input.</param> /// <param name="format">The format.</param> /// <returns></returns> public static string ConvertFromDateTime(DateTime input, TwitterDateFormat format) { EnsureDateFormatsAreMapped(); var name = Enum.GetName(typeof(TwitterDateFormat), format); GetReadLockOnMap(); var value = _map[name]; ReleaseReadLockOnMap(); value = value.Replace(" zzzzz", " +0000"); var converted = input.ToString(value, CultureInfo.InvariantCulture); return converted; }
/// <summary> /// Converts from date time. /// </summary> /// <param name="input">The input.</param> /// <param name="format">The format.</param> /// <returns></returns> public static string ConvertFromDateTime(DateTime input, TwitterDateFormat format) { EnsureDateFormatsAreMapped(); #if !SILVERLIGHT && !Smartphone var name = Enum.GetName(typeof(TwitterDateFormat), format); #else EnsureEnumNamesAreMapped(typeof (TwitterDateFormat)); var name = _names[_names.IndexOf(format.ToString())]; #endif GetReadLockOnMap(); var value = _map[name]; ReleaseReadLockOnMap(); value = value.Replace(" zzzzz", " +0000"); var converted = input.ToString(value, CultureInfo.InvariantCulture); return converted; }
/// <summary> /// Converts from date time. /// </summary> /// <param name="input">The input.</param> /// <param name="format">The format.</param> /// <returns></returns> public static string ConvertFromDateTime(DateTime input, TwitterDateFormat format) { EnsureDateFormatsAreMapped(); #if !SILVERLIGHT && !Smartphone var name = Enum.GetName(typeof(TwitterDateFormat), format); #else EnsureEnumNamesAreMapped(typeof(TwitterDateFormat)); var name = _names[_names.IndexOf(format.ToString())]; #endif GetReadLockOnMap(); var value = _map[name]; ReleaseReadLockOnMap(); value = value.Replace(" zzzzz", " +0000"); var converted = input.ToString(value, CultureInfo.InvariantCulture); return(converted); }
/// <summary> /// Initializes a new instance of the <see cref="TwitterDateTime"/> class. /// </summary> /// <param name="dateTime">The date time.</param> /// <param name="format">The format.</param> public TwitterDateTime(DateTime dateTime, TwitterDateFormat format) { Format = format; DateTime = dateTime; }