59
1
using System;
2
using System.Globalization;
3
using System.Collections;
4
5
public class Program
6
{
7
public static void Main()
8
{
9
Hashtable timezoneLookup = GetTimeZoneAbbreviationLookup();
10
string dateString, format;
11
DateTime result;
12
CultureInfo provider = CultureInfo.CurrentCulture;
13
14
// Example input: 'Wed Jan 11 08:37:19 CEST 2017'
15
dateString = "Wed Jan 11 08:37:19 CEST 2017";
16
string[] stzElements = dateString.Split(' '); // expecting 6 fields
17
// replace timezone abbreviation with the utc offset
18
stzElements[4] = (string)timezoneLookup[stzElements[4]];
19
20
// select proper timezone format, zzz if minutes are specified, zz otherwise
21
if (stzElements[4].Contains(":"))
22
{
23
format = "ddd MMM dd hh:mm:ss zzz yyyy";
24
}
Cached Result