예제 #1
0
파일: DateTime.cs 프로젝트: formist/LinkMe
        /// <summary>
        /// Constructor for recreating object during de-serialization
        /// </summary>
        /// <param name="info"></param>
        /// <param name="context"></param>
        private DateTime(SerializationInfo info, StreamingContext context)
        {
            m_universal  = info.GetDateTime("m_universal");
            m_nanosecond = info.GetInt32("m_nanosecond");

            bool isCurrentTimeZone = info.GetBoolean("isCurrentTimeZone");

            if (isCurrentTimeZone)
            {
                m_timeZone = System.TimeZone.CurrentTimeZone;
            }
            else
            {
                m_timeZone = (System.TimeZone)info.GetValue("m_timeZone", typeof(System.TimeZone));
            }
            Debug.Assert(m_timeZone != null, "m_timeZone != null");

            m_base = m_timeZone.ToLocalTime(m_universal);
        }
예제 #2
0
파일: DateTime.cs 프로젝트: formist/LinkMe
        // This constructor is for cloning. The nanosecond parameter is the total of microseconds and
        // nanoseconds (ie. 0 to 1000000).
        private DateTime(System.DateTime baseValue, int nanosecond, System.TimeZone timeZone,
                         bool isUniversalTime)
        {
            Debug.Assert(nanosecond >= 0 && nanosecond < 1000000, "The nanosecond value is invalid -"
                         + " an exception should be thrown immediately after this.");

            if (isUniversalTime)
            {
                m_universal = baseValue;
                m_base      = timeZone.ToLocalTime(baseValue);
            }
            else
            {
                m_base      = baseValue;
                m_universal = timeZone.ToUniversalTime(baseValue);
            }

            m_nanosecond = nanosecond;
            m_timeZone   = timeZone;
        }