2019-07-31 20:10:27 +01:00
|
|
|
// /***************************************************************************
|
2020-02-27 12:31:25 +00:00
|
|
|
// Aaru Data Preservation Suite
|
2019-07-31 20:10:27 +01:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// Filename : Date.cs
|
|
|
|
|
// Author(s) : Natalia Portillo <claunia@claunia.com>
|
|
|
|
|
//
|
|
|
|
|
// Component : ISO9660 filesystem plugin.
|
|
|
|
|
//
|
|
|
|
|
// --[ License ] --------------------------------------------------------------
|
|
|
|
|
//
|
|
|
|
|
// This library is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU Lesser General Public License as
|
|
|
|
|
// published by the Free Software Foundation; either version 2.1 of the
|
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This library is distributed in the hope that it will be useful, but
|
|
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
// License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
//
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2024-05-01 04:17:32 +01:00
|
|
|
// Copyright © 2011-2024 Natalia Portillo
|
2019-07-31 20:19:22 +01:00
|
|
|
// In the loving memory of Facunda "Tata" Suárez Domínguez, R.I.P. 2019/07/24
|
2019-07-31 20:10:27 +01:00
|
|
|
// ****************************************************************************/
|
|
|
|
|
|
2019-07-19 14:26:02 +01:00
|
|
|
using System;
|
2020-02-27 00:33:26 +00:00
|
|
|
using Aaru.Helpers;
|
2019-07-19 14:26:02 +01:00
|
|
|
|
2022-11-15 15:58:43 +00:00
|
|
|
namespace Aaru.Filesystems;
|
|
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
public sealed partial class ISO9660
|
2019-07-19 14:26:02 +01:00
|
|
|
{
|
2022-11-13 19:59:24 +00:00
|
|
|
static DateTime? DecodeIsoDateTime(byte[] timestamp) => timestamp?.Length switch
|
2023-10-03 23:22:08 +01:00
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
7 => DecodeIsoDateTime(Marshal
|
|
|
|
|
.ByteArrayToStructureLittleEndian<
|
2023-10-04 17:34:40 +01:00
|
|
|
IsoTimestamp>(timestamp)),
|
2023-10-03 23:22:08 +01:00
|
|
|
17 => DateHandlers.Iso9660ToDateTime(timestamp),
|
|
|
|
|
_ => null
|
|
|
|
|
};
|
2019-07-28 18:32:15 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
static DateTime? DecodeIsoDateTime(IsoTimestamp timestamp)
|
|
|
|
|
{
|
|
|
|
|
try
|
2019-07-19 14:59:35 +01:00
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
var date = new DateTime(timestamp.Years + 1900,
|
|
|
|
|
timestamp.Month,
|
|
|
|
|
timestamp.Day,
|
|
|
|
|
timestamp.Hour,
|
|
|
|
|
timestamp.Minute,
|
|
|
|
|
timestamp.Second,
|
|
|
|
|
DateTimeKind.Unspecified);
|
2019-07-19 14:59:35 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
date = date.AddMinutes(timestamp.GmtOffset * 15);
|
2019-07-19 14:59:35 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
return TimeZoneInfo.ConvertTimeToUtc(date, TimeZoneInfo.FindSystemTimeZoneById("GMT"));
|
|
|
|
|
}
|
|
|
|
|
catch(Exception)
|
|
|
|
|
{
|
|
|
|
|
// ISO says timestamp can be unspecified
|
|
|
|
|
return null;
|
2019-07-19 14:59:35 +01:00
|
|
|
}
|
2022-03-06 13:29:38 +00:00
|
|
|
}
|
2019-07-20 01:45:40 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
static DateTime? DecodeHighSierraDateTime(HighSierraTimestamp timestamp)
|
|
|
|
|
{
|
|
|
|
|
try
|
2019-07-20 01:45:40 +01:00
|
|
|
{
|
2024-05-01 04:05:22 +01:00
|
|
|
var date = new DateTime(timestamp.Years + 1900,
|
|
|
|
|
timestamp.Month,
|
|
|
|
|
timestamp.Day,
|
|
|
|
|
timestamp.Hour,
|
|
|
|
|
timestamp.Minute,
|
|
|
|
|
timestamp.Second,
|
|
|
|
|
DateTimeKind.Unspecified);
|
2019-07-20 01:45:40 +01:00
|
|
|
|
2022-03-06 13:29:38 +00:00
|
|
|
return TimeZoneInfo.ConvertTimeToUtc(date, TimeZoneInfo.FindSystemTimeZoneById("GMT"));
|
|
|
|
|
}
|
|
|
|
|
catch(Exception)
|
|
|
|
|
{
|
|
|
|
|
// ISO says timestamp can be unspecified, suppose same for High Sierra
|
|
|
|
|
return null;
|
2019-07-20 01:45:40 +01:00
|
|
|
}
|
2019-07-19 14:26:02 +01:00
|
|
|
}
|
|
|
|
|
}
|