mirror of
https://github.com/kwsch/PKHeX
synced 2024-12-12 05:32:40 +00:00
92c964d6fa
- Improve Epoch 1900 classes using similar logic from PlayTime7b. - Move Time Classes into non Gen specific folder since it appears the logic is shared across a few of them. - Use Epoch1900DateTimeValue for LastSaved in PlayTime7b since the logic is the same. - Remove TeamIndexes9 since it is a duplicate of TeamIndexes9. Use the similar pattern like Box8 where it is reused in multiple locations. - Add BlueberryClubRoom9 to ISaveBlock9Main since it wasn't added when the class was introduced. - Simplify RaidSevenStar9 creation since GetBlockSafe does basically what the if-else block does. - Change SAV8SWSH Base Raid to RaidGalar to match the same way the SAV9SV does for its Base Raid.
35 lines
1 KiB
C#
35 lines
1 KiB
C#
using System;
|
||
using System.ComponentModel;
|
||
using static System.Buffers.Binary.BinaryPrimitives;
|
||
|
||
namespace PKHeX.Core;
|
||
|
||
/// <summary>
|
||
/// Stores the <see cref="Timestamp"/> to indicate the seconds since 1970 that an event occurred.
|
||
/// </summary>
|
||
[TypeConverter(typeof(ExpandableObjectConverter))]
|
||
public sealed class Epoch1970Value(Memory<byte> Data)
|
||
{
|
||
private Span<byte> Span => Data.Span;
|
||
|
||
public Epoch1970Value(SCBlock block) : this(block.Data) { }
|
||
|
||
/// <summary>
|
||
/// time_t (seconds since 1970 Epoch)
|
||
/// </summary>
|
||
public ulong Seconds
|
||
{
|
||
get => ReadUInt64LittleEndian(Span);
|
||
set => WriteUInt64LittleEndian(Span, value);
|
||
}
|
||
|
||
private static DateTime Epoch => new(1970, 1, 1);
|
||
|
||
public string DisplayValue => $"{Timestamp.Year:0000}-{Timestamp.Month:00}-{Timestamp.Day:00} {Timestamp.Hour:00}ː{Timestamp.Minute:00}ː{Timestamp.Second:00}"; // not :
|
||
|
||
public DateTime Timestamp
|
||
{
|
||
get => Epoch.AddSeconds(Seconds);
|
||
set => Seconds = (ulong)value.Subtract(Epoch).TotalSeconds;
|
||
}
|
||
}
|