示例#1
0
        public void AlibabaTimeToNetTimeTest()
        {
            DateTime actual = AlibabaHelper.AlibabaTimeToLocalTime("20120801154220368+0800");

            Assert.IsTrue(actual.Year == 2012);
            Assert.IsTrue(actual.Month == 8);
            Assert.IsTrue(actual.Day == 1);
            Assert.IsTrue(actual.Hour == 15);
            Assert.IsTrue(actual.Minute == 42);
            Assert.IsTrue(actual.Second == 20);
            Assert.IsTrue(actual.Millisecond == 368);
            Assert.IsTrue(actual.Kind == DateTimeKind.Local);
        }
        public IAsyncResult BeginGetCurrentTime(AsyncCallback callback, object userState)
        {
            AsyncResult <DateTime> result = new AsyncResult <DateTime>(callback, userState);

            this.SendApiRequest(this.m_apiFacgory.GetSystemTime, null, (error, content) => {
                DateTime time = DateTime.MinValue;
                if (error == null)
                {
                    time = AlibabaHelper.AlibabaTimeToLocalTime(content.Substring(1, content.Length - 2));
                }

                result.MarkCompleted(error, false, time);
            });

            return(result);
        }