diff --git a/ExifLibrary/ExifExtendedProperty.cs b/ExifLibrary/ExifExtendedProperty.cs index f10a57d..2cfc369 100644 --- a/ExifLibrary/ExifExtendedProperty.cs +++ b/ExifLibrary/ExifExtendedProperty.cs @@ -146,6 +146,34 @@ public override ExifInterOperability Interoperability } } + /// + /// Represents an ASCII string formatted as Date. (EXIF Specification: ASCII) Used for the date fields. + /// + public class ExifDate : 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(ExifDate obj) { return obj.mValue; } + + public override string ToString() { return mValue.ToString("yyyy.MM.dd"); } + + public ExifDate(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)); + } + } + } + /// /// Represents the exif version as a 4 byte ASCII string. (EXIF Specification: UNDEFINED) /// Used for the ExifVersion, FlashpixVersion and InteroperabilityVersion fields. diff --git a/ExifLibrary/ExifPropertyFactory.cs b/ExifLibrary/ExifPropertyFactory.cs index d5c1e08..7fefbe3 100644 --- a/ExifLibrary/ExifPropertyFactory.cs +++ b/ExifLibrary/ExifPropertyFactory.cs @@ -169,8 +169,8 @@ public static ExifProperty Get(ushort tag, ushort type, uint count, byte[] value return new ExifEnumProperty(ExifTag.GPSDestBearingRef, (GPSDirectionRef)value[0]); else if (tag == 25) // GPSDestDistanceRef return new ExifEnumProperty(ExifTag.GPSDestDistanceRef, (GPSDistanceRef)value[0]); - else if (tag == 29) // GPSDate - return new ExifDateTime(ExifTag.GPSDateStamp, ExifBitConverter.ToDateTime(value, false)); + else if (tag == 29) // GPSDateStamp + return new ExifDate(ExifTag.GPSDateStamp, ExifBitConverter.ToDateTime(value, false)); else if (tag == 30) // GPSDifferential return new ExifEnumProperty(ExifTag.GPSDifferential, (GPSDifferential)conv.ToUInt16(value, 0)); }