/// <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; }