The implementation of XMPDateTime. Internally a calendar is used plus an additional nano seconds field, because Calendar supports only milli seconds. The nanoSeconds convers only the resolution beyond a milli second. @since 16.02.2006
Inheritance: XMPDateTime
Esempio n. 1
0
 /// <summary>
 /// Creates an <code>XMPDateTime</code>-object from initial values. </summary>
 /// <param name="year"> years </param>
 /// <param name="month"> months from 1 to 12<br>
 /// <em>Note:</em> Remember that the month in <seealso cref="Calendar"/> is defined from 0 to 11. </param>
 /// <param name="day"> days </param>
 /// <returns> Returns an <code>XMPDateTime</code>-object. </returns>
 public static IXmpDateTime Create(int year, int month, int day) {
     IXmpDateTime dt = new XmpDateTimeImpl();
     dt.Year = year;
     dt.Month = month;
     dt.Day = day;
     return dt;
 }
Esempio n. 2
0
        /// <summary>
        /// Fixes the GPS Timestamp in EXIF. </summary>
        /// <param name="exifSchema"> the EXIF schema node </param>
        /// <exception cref="XmpException"> Thrown if the date conversion fails. </exception>
        private static void FixGpsTimeStamp(XmpNode exifSchema)
        {
            // Note: if dates are not found the convert-methods throws an exceptions,
            //       and this methods returns.
            XmpNode gpsDateTime = XmpNodeUtils.FindChildNode(exifSchema, "exif:GPSTimeStamp", false);

            if (gpsDateTime == null)
            {
                return;
            }

            try {
                XMPDateTime binGpsStamp = XMPUtils.ConvertToDate(gpsDateTime.Value);
                if (binGpsStamp.Year != 0 || binGpsStamp.Month != 0 || binGpsStamp.Day != 0)
                {
                    return;
                }

                XmpNode otherDate = XmpNodeUtils.FindChildNode(exifSchema, "exif:DateTimeOriginal", false);
                otherDate = otherDate ?? XmpNodeUtils.FindChildNode(exifSchema, "exif:DateTimeDigitized", false);

                XMPDateTime binOtherDate = XMPUtils.ConvertToDate(otherDate.Value);
                XmpCalendar cal          = binGpsStamp.Calendar;
                DateTime    dt           = new DateTime(binOtherDate.Year, binOtherDate.Month, binOtherDate.Day, cal.DateTime.Hour,
                                                        cal.DateTime.Minute, cal.DateTime.Second, cal.DateTime.Millisecond);
                cal.DateTime      = dt;
                binGpsStamp       = new XmpDateTimeImpl(cal);
                gpsDateTime.Value = XMPUtils.ConvertFromDate(binGpsStamp);
            }
            catch (XmpException) {
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Creates an <code>XMPDateTime</code>-object from initial values. </summary>
 /// <param name="year"> years </param>
 /// <param name="month"> months from 1 to 12<br>
 /// <em>Note:</em> Remember that the month in <seealso cref="Calendar"/> is defined from 0 to 11. </param>
 /// <param name="day"> days </param>
 /// <param name="hour"> hours </param>
 /// <param name="minute"> minutes </param>
 /// <param name="second"> seconds </param>
 /// <param name="nanoSecond"> nanoseconds </param>
 /// <returns> Returns an <code>XMPDateTime</code>-object. </returns>
 public static IXmpDateTime Create(int year, int month, int day, int hour, int minute, int second, int nanoSecond) {
     IXmpDateTime dt = new XmpDateTimeImpl();
     dt.Year = year;
     dt.Month = month;
     dt.Day = day;
     dt.Hour = hour;
     dt.Minute = minute;
     dt.Second = second;
     dt.NanoSecond = nanoSecond;
     return dt;
 }
Esempio n. 4
0
        /// <summary>
        /// Fixes the GPS Timestamp in EXIF. </summary>
        /// <param name="exifSchema"> the EXIF schema node </param>
        /// <exception cref="XmpException"> Thrown if the date conversion fails. </exception>
        private static void FixGpsTimeStamp(XmpNode exifSchema) {
            // Note: if dates are not found the convert-methods throws an exceptions,
            // 		 and this methods returns.
            XmpNode gpsDateTime = XmpNodeUtils.FindChildNode(exifSchema, "exif:GPSTimeStamp", false);
            if (gpsDateTime == null) {
                return;
            }

            try {
                XMPDateTime binGpsStamp = XMPUtils.ConvertToDate(gpsDateTime.Value);
                if (binGpsStamp.Year != 0 || binGpsStamp.Month != 0 || binGpsStamp.Day != 0) {
                    return;
                }

                XmpNode otherDate = XmpNodeUtils.FindChildNode(exifSchema, "exif:DateTimeOriginal", false);
                otherDate = otherDate ?? XmpNodeUtils.FindChildNode(exifSchema, "exif:DateTimeDigitized", false);

                XMPDateTime binOtherDate = XMPUtils.ConvertToDate(otherDate.Value);
                XmpCalendar cal = binGpsStamp.Calendar;
                DateTime dt = new DateTime(binOtherDate.Year, binOtherDate.Month, binOtherDate.Day, cal.DateTime.Hour,
                                           cal.DateTime.Minute, cal.DateTime.Second, cal.DateTime.Millisecond);
                cal.DateTime = dt;
                binGpsStamp = new XmpDateTimeImpl(cal);
                gpsDateTime.Value = XMPUtils.ConvertFromDate(binGpsStamp);
            }
            catch (XmpException) {
            }
        }