49 lines
1.3 KiB
C#
49 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace mbts.utils
|
|
{
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct LLDateTime
|
|
{
|
|
public LLDateTime(UInt64 value) {
|
|
_value = value;
|
|
}
|
|
DateTime to_datetime() {
|
|
return _value.lldatetime();
|
|
}
|
|
|
|
public static implicit operator DateTime (LLDateTime time) { return time.to_datetime(); }
|
|
public static implicit operator LLDateTime (DateTime time) { return new LLDateTime((ulong)time.Ticks); }
|
|
|
|
public static LLDateTime now() {
|
|
return new LLDateTime(BTSNativeMethods.ll_now());
|
|
}
|
|
public UInt64 value => _value;
|
|
|
|
private UInt64 _value;
|
|
}
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
public struct LLDate
|
|
{
|
|
public ushort year;
|
|
public byte month;
|
|
public byte day;
|
|
|
|
DateTime to_date() {
|
|
if (year > 0 && month > 0 && day > 0) {
|
|
return new DateTime(year, month, day);
|
|
}
|
|
else return DateTime.MinValue;
|
|
}
|
|
public static implicit operator DateTime(LLDate date) {
|
|
return date.to_date();
|
|
}
|
|
}
|
|
}
|