Files
VR-WuKong/Packages/PICO Unity Integration SDK-3.3.2-20251111/Platform/Scripts/Framework/TimeUtil.cs
2025-11-13 17:40:28 +08:00

51 lines
1.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*******************************************************************************
Copyright © 2015-2022 PICO Technology Co., Ltd.All rights reserved.
NOTICEAll information contained herein is, and remains the property of
PICO Technology Co., Ltd. The intellectual and technical concepts
contained herein are proprietary to PICO Technology Co., Ltd. and may be
covered by patents, patents in process, and are protected by trade secret or
copyright law. Dissemination of this information or reproduction of this
material is strictly forbidden unless prior written permission is obtained from
PICO Technology Co., Ltd.
*******************************************************************************/
using System;
namespace Pico.Platform
{
public class TimeUtil
{
public static DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
public static int GetUtcSeconds()
{
return DateTimeToSeconds(DateTime.Now);
}
public static long GetUtcMilliSeconds()
{
return DateTimeToMilliSeconds(DateTime.Now);
}
public static int DateTimeToSeconds(DateTime t)
{
return (int) (t.ToUniversalTime() - UnixEpoch).TotalSeconds;
}
public static long DateTimeToMilliSeconds(DateTime t)
{
return (long) (t.ToUniversalTime() - UnixEpoch).TotalMilliseconds;
}
public static DateTime MilliSecondsToDateTime(long milliSeconds)
{
return UnixEpoch.AddMilliseconds(milliSeconds).ToLocalTime();
}
public static DateTime SecondsToDateTime(long seconds)
{
return UnixEpoch.AddSeconds(seconds).ToLocalTime();
}
}
}