NHSE/NHSE.Core/Structures/Misc/GSaveDate.cs
Kurt 60f3fa84a3 Add more misc edits
Closes #179
Not allowing people to import a jpeg.
2020-05-09 09:39:35 -07:00

30 lines
936 B
C#

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
#pragma warning disable CS8618, CA1815, CA1819, IDE1006
namespace NHSE.Core
{
[StructLayout(LayoutKind.Sequential, Pack = 4)]
[TypeConverter(typeof(ValueTypeTypeConverter))]
public struct GSaveDate
{
public const int SIZE = 4;
public override string ToString() => $"{Year:0000}-{Month:00}-{Day:00}";
public ushort Year { get; set; }
public byte Month { get; set; }
public byte Day { get; set; }
private GSaveDate(int year, int month, int day)
{
Year = (ushort) year;
Month = (byte) month;
Day = (byte) day;
}
public static implicit operator GSaveDate(DateTime dt) => new GSaveDate(dt.Year, dt.Month, dt.Day);
public static implicit operator DateTime(GSaveDate dt) => new DateTime(dt.Year, dt.Month, dt.Day);
}
}