mirror of
https://github.com/aaru-dps/Aaru.Helpers.git
synced 2025-12-16 19:24:35 +00:00
[Aaru.Helpers] Reformat and cleanup.
This commit is contained in:
@@ -91,7 +91,7 @@ public static class DateHandlers
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime HighSierraToDateTime(byte[] vdDateTime)
|
||||
{
|
||||
byte[] isoTime = new byte[17];
|
||||
var isoTime = new byte[17];
|
||||
Array.Copy(vdDateTime, 0, isoTime, 0, 16);
|
||||
|
||||
return Iso9660ToDateTime(isoTime);
|
||||
@@ -103,8 +103,8 @@ public static class DateHandlers
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime Iso9660ToDateTime(byte[] vdDateTime)
|
||||
{
|
||||
byte[] twoCharValue = new byte[2];
|
||||
byte[] fourCharValue = new byte[4];
|
||||
var twoCharValue = new byte[2];
|
||||
var fourCharValue = new byte[4];
|
||||
|
||||
fourCharValue[0] = vdDateTime[0];
|
||||
fourCharValue[1] = vdDateTime[1];
|
||||
@@ -175,7 +175,7 @@ public static class DateHandlers
|
||||
"decodedDT = new DateTime({0}, {1}, {2}, {3}, {4}, {5}, {6}, DateTimeKind.Unspecified);",
|
||||
year, month, day, hour, minute, second, hundredths * 10);
|
||||
|
||||
sbyte difference = (sbyte)vdDateTime[16];
|
||||
var difference = (sbyte)vdDateTime[16];
|
||||
|
||||
var decodedDt = new DateTime(year, month, day, hour, minute, second, hundredths * 10, DateTimeKind.Utc);
|
||||
|
||||
@@ -260,9 +260,9 @@ public static class DateHandlers
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime CpmToDateTime(byte[] timestamp)
|
||||
{
|
||||
ushort days = BitConverter.ToUInt16(timestamp, 0);
|
||||
int hours = timestamp[2];
|
||||
int minutes = timestamp[3];
|
||||
var days = BitConverter.ToUInt16(timestamp, 0);
|
||||
int hours = timestamp[2];
|
||||
int minutes = timestamp[3];
|
||||
|
||||
DateTime temp = _amigaEpoch.AddDays(days);
|
||||
temp = temp.AddHours(hours);
|
||||
@@ -284,18 +284,18 @@ public static class DateHandlers
|
||||
/// <param name="microseconds">Microseconds</param>
|
||||
/// <returns></returns>
|
||||
public static DateTime EcmaToDateTime(ushort typeAndTimeZone, short year, byte month, byte day, byte hour,
|
||||
byte minute, byte second, byte centiseconds, byte hundredsOfMicroseconds,
|
||||
byte microseconds)
|
||||
byte minute, byte second, byte centiseconds, byte hundredsOfMicroseconds,
|
||||
byte microseconds)
|
||||
{
|
||||
byte specification = (byte)((typeAndTimeZone & 0xF000) >> 12);
|
||||
var specification = (byte)((typeAndTimeZone & 0xF000) >> 12);
|
||||
|
||||
long ticks = ((long)centiseconds * 100000) + ((long)hundredsOfMicroseconds * 1000) + ((long)microseconds * 10);
|
||||
long ticks = (long)centiseconds * 100000 + (long)hundredsOfMicroseconds * 1000 + (long)microseconds * 10;
|
||||
|
||||
if(specification == 0)
|
||||
return new DateTime(year, month, day, hour, minute, second, DateTimeKind.Utc).AddTicks(ticks);
|
||||
|
||||
ushort preOffset = (ushort)(typeAndTimeZone & 0xFFF);
|
||||
short offset;
|
||||
var preOffset = (ushort)(typeAndTimeZone & 0xFFF);
|
||||
short offset;
|
||||
|
||||
if((preOffset & 0x800) == 0x800)
|
||||
offset = (short)(preOffset | 0xF000);
|
||||
@@ -327,15 +327,16 @@ public static class DateHandlers
|
||||
public static DateTime Os9ToDateTime(byte[] date)
|
||||
{
|
||||
if(date == null ||
|
||||
(date.Length != 3 && date.Length != 5))
|
||||
date.Length != 3 && date.Length != 5)
|
||||
return DateTime.MinValue;
|
||||
|
||||
DateTime os9Date;
|
||||
|
||||
try
|
||||
{
|
||||
os9Date = date.Length == 5 ? new DateTime(1900 + date[0], date[1], date[2], date[3], date[4], 0)
|
||||
: new DateTime(1900 + date[0], date[1], date[2], 0, 0, 0);
|
||||
os9Date = date.Length == 5
|
||||
? new DateTime(1900 + date[0], date[1], date[2], date[3], date[4], 0)
|
||||
: new DateTime(1900 + date[0], date[1], date[2], 0, 0, 0);
|
||||
}
|
||||
catch(ArgumentOutOfRangeException)
|
||||
{
|
||||
@@ -348,7 +349,8 @@ public static class DateHandlers
|
||||
/// <summary>Converts a LIF timestamp to .NET DateTime</summary>
|
||||
/// <param name="date">LIF timestamp</param>
|
||||
/// <returns>.NET DateTime</returns>
|
||||
public static DateTime LifToDateTime(byte[] date) => date is not { Length: 6 } ? new DateTime(1970, 1, 1, 0, 0, 0)
|
||||
public static DateTime LifToDateTime(byte[] date) => date is not { Length: 6 }
|
||||
? new DateTime(1970, 1, 1, 0, 0, 0)
|
||||
: LifToDateTime(date[0], date[1], date[2], date[3],
|
||||
date[4], date[5]);
|
||||
|
||||
@@ -364,12 +366,12 @@ public static class DateHandlers
|
||||
{
|
||||
try
|
||||
{
|
||||
int iyear = ((year >> 4) * 10) + (year & 0xF);
|
||||
int imonth = ((month >> 4) * 10) + (month & 0xF);
|
||||
int iday = ((day >> 4) * 10) + (day & 0xF);
|
||||
int iminute = ((minute >> 4) * 10) + (minute & 0xF);
|
||||
int ihour = ((hour >> 4) * 10) + (hour & 0xF);
|
||||
int isecond = ((second >> 4) * 10) + (second & 0xF);
|
||||
int iyear = (year >> 4) * 10 + (year & 0xF);
|
||||
int imonth = (month >> 4) * 10 + (month & 0xF);
|
||||
int iday = (day >> 4) * 10 + (day & 0xF);
|
||||
int iminute = (minute >> 4) * 10 + (minute & 0xF);
|
||||
int ihour = (hour >> 4) * 10 + (hour & 0xF);
|
||||
int isecond = (second >> 4) * 10 + (second & 0xF);
|
||||
|
||||
if(iyear >= 70)
|
||||
iyear += 1900;
|
||||
|
||||
Reference in New Issue
Block a user