コード例 #1
0
        /// <summary>Fixes the GPS Timestamp in EXIF.</summary>
        /// <param name="exifSchema">the EXIF schema node</param>
        /// <exception cref="iText.Kernel.XMP.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.GetValue());
                if (binGpsStamp.GetYear() != 0 || binGpsStamp.GetMonth() != 0 || binGpsStamp.GetDay() != 0)
                {
                    return;
                }

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

                XMPDateTime binOtherDate = XMPUtils.ConvertToDate(otherDate.GetValue());
                XMPCalendar cal          = binGpsStamp.GetCalendar();
                DateTime    dt           = new DateTime(binOtherDate.GetYear(), binOtherDate.GetMonth(), binOtherDate.GetDay(),
                                                        cal.GetDateTime().Hour, cal.GetDateTime().Minute, cal.GetDateTime().Second, cal.GetDateTime().Millisecond);
                cal.SetDateTime(dt);
                binGpsStamp = new XMPDateTimeImpl(cal);
                gpsDateTime.SetValue(XMPUtils.ConvertFromDate(binGpsStamp));
            }
            catch (XMPException) {
            }
        }
コード例 #2
0
        /// <summary>
        /// Creates an <code>XMPDateTime</code>-instance from a calendar.
        /// </summary>
        /// <param name="calendar"> a <code>Calendar</code> </param>
        public XmpDateTimeImpl(XMPCalendar calendar) {
            // extract the date and timezone from the calendar provided
            DateTime date = calendar.DateTime;
            TimeZone zone = calendar.TimeZone;

            _year = date.Year;
            _month = date.Month + 1; // cal is from 0..12
            _day = date.Day;
            _hour = date.Hour;
            _minute = date.Minute;
            _second = date.Second;
            _nanoSeconds = date.Millisecond*1000000;
            _timeZone = zone;

            // object contains all date components
            _hasDate = _hasTime = _hasTimeZone = true;
        }
コード例 #3
0
        /// <summary>
        /// Creates an <code>XMPDateTime</code>-instance from a calendar.
        /// </summary>
        /// <param name="calendar"> a <code>Calendar</code> </param>
        public XMPDateTimeImpl(XMPCalendar calendar)
        {
            // extract the date and timezone from the calendar provided
            DateTime date = calendar.GetDateTime();
            TimeZone zone = calendar.GetTimeZone();

            year        = date.Year;
            month       = date.Month + 1;       // cal is from 0..12
            day         = date.Day;
            hour        = date.Hour;
            minute      = date.Minute;
            second      = date.Second;
            nanoSeconds = date.Millisecond * 1000000;
            timeZone    = zone;

            // object contains all date components
            hasDate = hasTime = hasTimeZone = true;
        }
コード例 #4
0
        /// <summary>
        /// Creates an <code>XMPDateTime</code>-instance from a calendar.
        /// </summary>
        /// <param name="calendar"> a <code>Calendar</code> </param>
        public XmpDateTimeImpl(XMPCalendar calendar)
        {
            // extract the date and timezone from the calendar provided
            DateTime date = calendar.DateTime;
            TimeZone zone = calendar.TimeZone;

            _year        = date.Year;
            _month       = date.Month + 1; // cal is from 0..12
            _day         = date.Day;
            _hour        = date.Hour;
            _minute      = date.Minute;
            _second      = date.Second;
            _nanoSeconds = date.Millisecond * 1000000;
            _timeZone    = zone;

            // object contains all date components
            _hasDate = _hasTime = _hasTimeZone = true;
        }