示例#1
0
        public SipperTimeStamp(string timeStr)
        {
            hour   = 0;
            minute = 0;
            second = 0;

            string[] fields = timeStr.Split(':');
            if (fields.Length != 3)
            {
                return;
            }

            hour = PicesKKStr.StrToByte(fields[0]);
            if ((hour < 0) || (hour > 24))
            {
                hour = 0;
                return;
            }

            minute = PicesKKStr.StrToByte(fields[1]);
            if ((minute < 0) || (minute > 60))
            {
                minute = 0;
                return;
            }

            second = PicesKKStr.StrToByte(fields[2]);
            if ((second < 0) || (second > 60))
            {
                second = 0;
                return;
            }
        }
示例#2
0
        public SipperDateStamp(string dateStr)
        {
            dayOfWeek = 1;
            day       = 1;
            month     = 1;
            year      = 8;

            bool validDate = true;

            // Expect string in format of  'mm/dd/yy'
            string[] fields = dateStr.Split('/');
            if (fields.Length != 3)
            {
                return;
            }

            month = PicesKKStr.StrToByte(fields[0]);
            if ((month < 1) || (month > 12))
            {
                validDate = false;
            }

            day = PicesKKStr.StrToByte(fields[1]);
            if ((day < 1) || (day > 31))
            {
                validDate = false;
            }

            uint xxx = PicesKKStr.StrToUint(fields[2]);

            if (xxx > 2000)
            {
                xxx = xxx - 2000;
                if (xxx < 100)
                {
                    year = (byte)xxx;
                }
            }
            if (!validDate)
            {
                DateTime dt = DateTime.Now;
                month = 1;
                day   = 1;
                year  = 1;
            }

            return;
        }