/// <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 /// <see cref="Sharpen.Calendar"/> /// is defined from 0 to 11. /// </param> /// <param name="day">days</param> /// <returns>Returns an <code>XMPDateTime</code>-object.</returns> public static XMPDateTime Create(int year, int month, int day) { XMPDateTime dt = new XMPDateTimeImpl(); dt.SetYear(year); dt.SetMonth(month); dt.SetDay(day); return dt; }
/// <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 /// <see cref="Sharpen.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 XMPDateTime Create(int year, int month, int day, int hour, int minute, int second, int nanoSecond) { XMPDateTime dt = new XMPDateTimeImpl(); dt.SetYear(year); dt.SetMonth(month); dt.SetDay(day); dt.SetHour(hour); dt.SetMinute(minute); dt.SetSecond(second); dt.SetNanoSecond(nanoSecond); return dt; }
/// <summary>Fixes the GPS Timestamp in EXIF.</summary> /// <param name="exifSchema">the EXIF schema node</param> /// <exception cref="Com.Adobe.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; XMPDateTime binOtherDate; binGPSStamp = XMPUtils.ConvertToDate(gpsDateTime.GetValue()); if (binGPSStamp.GetYear() != 0 || binGPSStamp.GetMonth() != 0 || binGPSStamp.GetDay() != 0) { return; } XMPNode otherDate = XMPNodeUtils.FindChildNode(exifSchema, "exif:DateTimeOriginal", false); if (otherDate == null) { otherDate = XMPNodeUtils.FindChildNode(exifSchema, "exif:DateTimeDigitized", false); } binOtherDate = XMPUtils.ConvertToDate(otherDate.GetValue()); Sharpen.Calendar cal = binGPSStamp.GetCalendar(); cal.Set(Sharpen.CalendarEnum.Year, binOtherDate.GetYear()); cal.Set(Sharpen.CalendarEnum.Month, binOtherDate.GetMonth()); cal.Set(Sharpen.CalendarEnum.DayOfMonth, binOtherDate.GetDay()); binGPSStamp = new XMPDateTimeImpl(cal); gpsDateTime.SetValue(XMPUtils.ConvertFromDate(binGPSStamp)); } catch (XMPException) { // Don't let a missing or bad date stop other things. return; } }
public virtual void UpdateDate(int tagType, DateTime value) { base.SetDate(tagType, value); XMPDateTime date = new XMPDateTimeImpl(value, System.TimeZoneInfo.Local); try { GetXMPMeta().SetPropertyDate(_tagSchemaMap.Get(tagType), _tagPropNameMap.Get(tagType), date); } catch (XMPException e) { Sharpen.Runtime.PrintStackTrace(e); } }