oozcitak / exiflibrary

A .Net Standard library for editing Exif metadata
MIT License
134 stars 48 forks source link

error in GPSDateStamp #58

Closed FSofTlpz closed 6 years ago

FSofTlpz commented 6 years ago

GPSDateStamp is only a (ASCII-)date with format "YYYY:MM:DD", not a DateTime.

My solution:

Change in ExifPropertyFactory.cs, line 172, ExifDateTime to GPSDateStamp: else if (tag == 29) // GPSDate return new GPSDateStamp(ExifTag.GPSDateStamp, ExifBitConverter.ToDateTime(value, false));

Add in ExifExtendedProperty.cs: public class GPSDateStamp : ExifProperty { protected DateTime mValue; protected override object _Value { get { return Value; } set { Value = (DateTime)value; } } public new DateTime Value { get { return mValue; } set { mValue = value; } }

  static public implicit operator DateTime(GPSDateStamp obj) { return obj.mValue; }

  public override string ToString() { return mValue.ToString("yyyy:MM:dd"); }

  public GPSDateStamp(ExifTag tag, DateTime value)
      : base(tag) {
     mValue = value;
  }

  public override ExifInterOperability Interoperability {
     get {
        return new ExifInterOperability(ExifTagFactory.GetTagID(mTag), 2, (uint)11, ExifBitConverter.GetBytes(mValue, false));
     }
  }

}