/// <summary>Creates an <code>XMPDateTime</code>-instance from a calendar.</summary>
        /// <param name="calendar">a <code>Calendar</code></param>
        public XMPDateTimeImpl(Sharpen.Calendar calendar)
        {
            // EMPTY
            // extract the date and timezone from the calendar provided
            DateTime     date = calendar.GetTime();
            TimeZoneInfo zone = calendar.GetTimeZone();

            // put that date into a calendar the pretty much represents ISO8601
            // I use US because it is close to the "locale" for the ISO8601 spec
            Sharpen.GregorianCalendar intCalendar = (Sharpen.GregorianCalendar)Sharpen.Calendar.GetInstance(CultureInfo.InvariantCulture);
            intCalendar.SetGregorianChange(Sharpen.Extensions.CreateDate(long.MinValue));
            intCalendar.SetTimeZone(zone);
            intCalendar.SetTime(date);
            this.year  = intCalendar.Get(Sharpen.CalendarEnum.Year);
            this.month = intCalendar.Get(Sharpen.CalendarEnum.Month) + 1;
            // cal is from 0..12
            this.day         = intCalendar.Get(Sharpen.CalendarEnum.DayOfMonth);
            this.hour        = intCalendar.Get(Sharpen.CalendarEnum.HourOfDay);
            this.minute      = intCalendar.Get(Sharpen.CalendarEnum.Minute);
            this.second      = intCalendar.Get(Sharpen.CalendarEnum.Second);
            this.nanoSeconds = intCalendar.Get(Sharpen.CalendarEnum.Millisecond) * 1000000;
            this.timeZone    = intCalendar.GetTimeZone();
            // object contains all date components
            hasDate = hasTime = hasTimeZone = true;
        }
示例#2
0
 /// <summary>Creates an <c>XMPDateTime</c>-instance from a calendar.</summary>
 /// <param name="calendar">a <c>Calendar</c></param>
 public XmpDateTime(Calendar calendar)
 {
     // extract the date and timezone from the calendar provided
     var date = calendar.GetTime();
     var zone = calendar.GetTimeZone();
     // put that date into a calendar the pretty much represents ISO8601
     // I use US because it is close to the "locale" for the ISO8601 spec
     var intCalendar = (GregorianCalendar)Calendar.GetInstance(CultureInfo.InvariantCulture);
     intCalendar.SetGregorianChange(UnixTimeToDateTime(long.MinValue));
     intCalendar.SetTimeZone(zone);
     intCalendar.SetTime(date);
     _year = intCalendar.Get(CalendarEnum.Year);
     _month = intCalendar.Get(CalendarEnum.Month) + 1;
     // cal is from 0..12
     _day = intCalendar.Get(CalendarEnum.DayOfMonth);
     _hour = intCalendar.Get(CalendarEnum.HourOfDay);
     _minute = intCalendar.Get(CalendarEnum.Minute);
     _second = intCalendar.Get(CalendarEnum.Second);
     _nanoseconds = intCalendar.Get(CalendarEnum.Millisecond) * 1000000;
     _timeZone = intCalendar.GetTimeZone();
     // object contains all date components
     HasDate = HasTime = HasTimeZone = true;
 }
示例#3
0
        /// <summary>Creates an <c>XMPDateTime</c>-instance from a calendar.</summary>
        /// <param name="calendar">a <c>Calendar</c></param>
        public XmpDateTime(Calendar calendar)
        {
            // extract the date and timezone from the calendar provided
            var date = calendar.GetTime();
            var zone = calendar.GetTimeZone();
            // put that date into a calendar the pretty much represents ISO8601
            // I use US because it is close to the "locale" for the ISO8601 spec
            var intCalendar = (GregorianCalendar)Calendar.GetInstance(CultureInfo.InvariantCulture);

            intCalendar.SetGregorianChange(UnixTimeToDateTime(long.MinValue));
            intCalendar.SetTimeZone(zone);
            intCalendar.SetTime(date);
            _year  = intCalendar.Get(CalendarEnum.Year);
            _month = intCalendar.Get(CalendarEnum.Month) + 1;
            // cal is from 0..12
            _day         = intCalendar.Get(CalendarEnum.DayOfMonth);
            _hour        = intCalendar.Get(CalendarEnum.HourOfDay);
            _minute      = intCalendar.Get(CalendarEnum.Minute);
            _second      = intCalendar.Get(CalendarEnum.Second);
            _nanoseconds = intCalendar.Get(CalendarEnum.Millisecond) * 1000000;
            _timeZone    = intCalendar.GetTimeZone();
            // object contains all date components
            HasDate = HasTime = HasTimeZone = true;
        }