MonoHttpDate.cs 924 B

123456789101112131415161718192021222324252627282930313233
  1. //
  2. // System.Net.MonoHttpDate
  3. //
  4. // Author:
  5. // Lawrence Pit ([email protected])
  6. //
  7. using System;
  8. using System.Globalization;
  9. namespace System.Net
  10. {
  11. /// <summary>
  12. /// See RFC 2068 3.3.1
  13. /// </summary>
  14. internal class MonoHttpDate
  15. {
  16. private static readonly string rfc1123_date = "r";
  17. private static readonly string rfc850_date = "dddd, dd-MMM-yy HH:mm:ss G\\MT";
  18. private static readonly string asctime_date = "ddd MMM d HH:mm:ss yyyy";
  19. private static readonly string [] formats =
  20. new string [] {rfc1123_date, rfc850_date, asctime_date};
  21. private static readonly CultureInfo enUS = new CultureInfo("en-US", false);
  22. internal static DateTime Parse (string dateStr)
  23. {
  24. return DateTime.ParseExact (dateStr,
  25. formats,
  26. enUS,
  27. DateTimeStyles.AllowWhiteSpaces);
  28. }
  29. }
  30. }