Authored Unity primitive/object-model shim, VFX layer (control-flow-preserving, InstantVfx never invokes its action -- headless suppression), god-object stubs (GameMgr/EffectMgr/UIManager with faithfully-extracted nested enums), View/UI/Touch tree, LitJson+BetterList+Tuple copied, third-party stubs. Discovered Roslyn header-error masking: fixing class-header type errors unmasks body references, so the true copy closure is ~2570 files (was 782 under masking). Errors: masked-25720 -> 268; our shim files compile clean. Remaining: ~50 residual shim/external types, 24 NGUI UI-base overrides, static-type fixes, plus likely 1-2 more unmask waves.
148 lines
3.2 KiB
C#
148 lines
3.2 KiB
C#
using System;
|
|
|
|
namespace Cute;
|
|
|
|
public class TimeUtil
|
|
{
|
|
public struct TimeLeftParam
|
|
{
|
|
public int day;
|
|
|
|
public int hour;
|
|
|
|
public int minute;
|
|
|
|
public int second;
|
|
|
|
public int millisecond;
|
|
|
|
public int count;
|
|
|
|
public bool isEnd;
|
|
|
|
public bool isCharge;
|
|
|
|
public TimeLeftParam(long unixTime, long consumingTime)
|
|
{
|
|
if (unixTime <= 0)
|
|
{
|
|
isEnd = true;
|
|
count = 0;
|
|
day = 0;
|
|
hour = 0;
|
|
minute = 0;
|
|
second = 0;
|
|
millisecond = 0;
|
|
isCharge = true;
|
|
return;
|
|
}
|
|
isEnd = false;
|
|
if (consumingTime == 0L)
|
|
{
|
|
count = 0;
|
|
isCharge = false;
|
|
}
|
|
else
|
|
{
|
|
count = (int)(unixTime / consumingTime) + 1;
|
|
unixTime = unixTime - (count - 1) * consumingTime + 1;
|
|
if (unixTime == consumingTime)
|
|
{
|
|
isCharge = true;
|
|
}
|
|
else
|
|
{
|
|
isCharge = false;
|
|
}
|
|
}
|
|
day = (int)unixTime / 86400;
|
|
hour = (int)unixTime / 3600 % 24;
|
|
minute = (int)unixTime / 60 % 60;
|
|
second = (int)unixTime % 60;
|
|
millisecond = (int)unixTime % 1000;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"回数{count:D2}残り{day:D2}日 {hour:D2}:{minute:D2}:{second:D2}";
|
|
}
|
|
}
|
|
|
|
private static readonly DateTime UNIX_EPOCH = new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
|
|
|
public const int DAY_HOUR = 24;
|
|
|
|
public const int DAY_SECOND = 86400;
|
|
|
|
public const int HOUR_SECOND = 3600;
|
|
|
|
public const int MINUTE_SECOND = 60;
|
|
|
|
public const int MILLI_SECOND = 1000;
|
|
|
|
public static DateTime GetNowTime(long serverTime, long connectClientTime)
|
|
{
|
|
return UNIX_EPOCH.AddSeconds((float)serverTime + TimeNativePlugin.GetDeviceOperatingTime() - (float)connectClientTime).ToLocalTime();
|
|
}
|
|
|
|
public static DateTime GetNowTime_UTC(long serverTime, long connectClientTime)
|
|
{
|
|
return UNIX_EPOCH.AddSeconds((float)serverTime + TimeNativePlugin.GetDeviceOperatingTime() - (float)connectClientTime);
|
|
}
|
|
|
|
public static DateTime GetAbsoluteTime()
|
|
{
|
|
return UNIX_EPOCH.AddSeconds(TimeNativePlugin.GetDeviceOperatingTime());
|
|
}
|
|
|
|
public static long ToUnixTime(string str)
|
|
{
|
|
if (str == null)
|
|
{
|
|
return 0L;
|
|
}
|
|
return ToUnixTime(DateTime.Parse(str));
|
|
}
|
|
|
|
public static long ToUnixTime(DateTime dateTime)
|
|
{
|
|
return (long)ToUnixTimeDouble(dateTime);
|
|
}
|
|
|
|
public static double ToUnixTimeDouble(DateTime dateTime)
|
|
{
|
|
dateTime = dateTime.ToUniversalTime();
|
|
return (dateTime - UNIX_EPOCH).TotalSeconds;
|
|
}
|
|
|
|
public static DateTime FromUnixTime(long unixTime)
|
|
{
|
|
return UNIX_EPOCH.AddSeconds(Convert.ToDouble(unixTime)).ToLocalTime();
|
|
}
|
|
|
|
public static DateTime MicroTimeToFromUnixTime(long unixTime)
|
|
{
|
|
return FromUnixTime(unixTime / 1000);
|
|
}
|
|
|
|
public static TimeLeftParam GetTimeLeft(long nowTime, long endTime, long consumingTime = 0L)
|
|
{
|
|
return new TimeLeftParam(endTime - nowTime, consumingTime);
|
|
}
|
|
|
|
public static long GetElapsedTime(DateTime baseDateTime, DateTime dateTime)
|
|
{
|
|
return ToUnixTime(dateTime) - ToUnixTime(baseDateTime);
|
|
}
|
|
|
|
public static TimeSpan GetElapsedTimeByTimeSpan(DateTime baseDateTime, DateTime dateTime)
|
|
{
|
|
return baseDateTime - dateTime;
|
|
}
|
|
|
|
public static bool IsTermTime(string startDate, string endDate, long checkTime = 0L)
|
|
{
|
|
return true;
|
|
}
|
|
}
|