TryParseTimestamp() 공개 메소드

public TryParseTimestamp ( string timeStamp, System.DateTime &dateTime ) : bool
timeStamp string
dateTime System.DateTime
리턴 bool
예제 #1
0
        public void ParserTimestampTimeMode()
        {
            PscpClient.ScpLineParser parser = new PscpClient.ScpLineParser();
            DateTime dt;

            Assert.True(parser.TryParseTimestamp("May 15 12:32", out dt));
            Assert.AreEqual(DateTime.Now.Year, dt.Year);
            Assert.AreEqual(5, dt.Month);
            Assert.AreEqual(15, dt.Day);
            Assert.AreEqual(12, dt.Hour);
            Assert.AreEqual(32, dt.Minute);
            Assert.AreEqual(DateTimeKind.Local, dt.Kind);

            Assert.True(parser.TryParseTimestamp("Mar  3 03:37", out dt));
            Assert.AreEqual(DateTime.Now.Year, dt.Year);
            Assert.AreEqual(3, dt.Month);
            Assert.AreEqual(3, dt.Day);
            Assert.AreEqual(3, dt.Hour);
            Assert.AreEqual(37, dt.Minute);
            Assert.AreEqual(DateTimeKind.Local, dt.Kind);

            Assert.True(parser.TryParseTimestamp("Nov 18 18:19", out dt));
            Assert.AreEqual(DateTime.Now.Year, dt.Year);
            Assert.AreEqual(11, dt.Month);
            Assert.AreEqual(18, dt.Day);
            Assert.AreEqual(18, dt.Hour);
            Assert.AreEqual(19, dt.Minute);
            Assert.AreEqual(DateTimeKind.Local, dt.Kind);
        }
예제 #2
0
        public void ParserTimestampYearMode()
        {
            // May 15 12:32, Mar  3 03:37, Nov 18 18:19, May 27  2012
            PscpClient.ScpLineParser parser = new PscpClient.ScpLineParser();
            DateTime dt;

            Assert.True(parser.TryParseTimestamp("May 15 2012", out dt));
            Assert.AreEqual(2012, dt.Year);
            Assert.AreEqual(5, dt.Month);
            Assert.AreEqual(15, dt.Day);
            Assert.AreEqual(0, dt.Hour);
            Assert.AreEqual(0, dt.Minute);
            Assert.AreEqual(DateTimeKind.Local, dt.Kind);

            Assert.True(parser.TryParseTimestamp("May  5 2012", out dt));
            Assert.AreEqual(2012, dt.Year);
            Assert.AreEqual(5, dt.Month);
            Assert.AreEqual(5, dt.Day);
            Assert.AreEqual(0, dt.Hour);
            Assert.AreEqual(0, dt.Minute);
            Assert.AreEqual(DateTimeKind.Local, dt.Kind);
        }