public static bool GMTStrParse(string gmtStr,out DateTime gmtTime) { CultureInfo enUS = new CultureInfo("en-US"); bool s = DateTime.TryParseExact(gmtStr, "r", enUS, DateTimeStyles.None, out gmtTime); return s; }
测试
public class Test_Aliyun : TestMono { public void GMTStrPrase() { string gmtStr = System.DateTime.UtcNow.ToString("r"); print("GMT String:"+gmtStr); DateTime date; bool s = OSS.Credentials.GMTStrParse(gmtStr, out date); print("Parse:"+s); print("GMT:"+date.ToString("r")); } }
测试结果: