2019-07-19 14:26:02 +01:00
|
|
|
using System;
|
2019-07-28 18:32:15 +01:00
|
|
|
using DiscImageChef.Helpers;
|
2019-07-19 14:26:02 +01:00
|
|
|
|
|
|
|
|
namespace DiscImageChef.Filesystems.ISO9660
|
|
|
|
|
{
|
|
|
|
|
public partial class ISO9660
|
|
|
|
|
{
|
2019-07-31 19:53:47 +01:00
|
|
|
static DateTime? DecodeIsoDateTime(byte[] timestamp)
|
2019-07-28 18:32:15 +01:00
|
|
|
{
|
|
|
|
|
switch(timestamp?.Length)
|
|
|
|
|
{
|
|
|
|
|
case 7: return DecodeIsoDateTime(Marshal.ByteArrayToStructureLittleEndian<IsoTimestamp>(timestamp));
|
|
|
|
|
case 17: return DateHandlers.Iso9660ToDateTime(timestamp);
|
|
|
|
|
default: return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-31 19:53:47 +01:00
|
|
|
static DateTime? DecodeIsoDateTime(IsoTimestamp timestamp)
|
2019-07-19 14:59:35 +01:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DateTime date = new DateTime(timestamp.Years + 1900, timestamp.Month, timestamp.Day, timestamp.Hour,
|
|
|
|
|
timestamp.Minute, timestamp.Second, DateTimeKind.Unspecified);
|
|
|
|
|
|
|
|
|
|
date = date.AddMinutes(timestamp.GmtOffset * 15);
|
|
|
|
|
|
|
|
|
|
return TimeZoneInfo.ConvertTimeToUtc(date, TimeZoneInfo.FindSystemTimeZoneById("GMT"));
|
|
|
|
|
}
|
2019-07-31 19:53:47 +01:00
|
|
|
catch(Exception)
|
2019-07-19 14:59:35 +01:00
|
|
|
{
|
|
|
|
|
// ISO says timestamp can be unspecified
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-20 01:45:40 +01:00
|
|
|
|
2019-07-31 19:53:47 +01:00
|
|
|
static DateTime? DecodeHighSierraDateTime(HighSierraTimestamp timestamp)
|
2019-07-20 01:45:40 +01:00
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DateTime date = new DateTime(timestamp.Years + 1900, timestamp.Month, timestamp.Day, timestamp.Hour,
|
|
|
|
|
timestamp.Minute, timestamp.Second, DateTimeKind.Unspecified);
|
|
|
|
|
|
|
|
|
|
return TimeZoneInfo.ConvertTimeToUtc(date, TimeZoneInfo.FindSystemTimeZoneById("GMT"));
|
|
|
|
|
}
|
2019-07-31 19:53:47 +01:00
|
|
|
catch(Exception)
|
2019-07-20 01:45:40 +01:00
|
|
|
{
|
|
|
|
|
// ISO says timestamp can be unspecified, suppose same for High Sierra
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-07-19 14:26:02 +01:00
|
|
|
}
|
|
|
|
|
}
|