zoukankan      html  css  js  c++  java
  • System.DateTimeOffset 中新增的Unix 时间戳方法

    // System.DateTimeOffset
    [__DynamicallyInvokable]
    public static DateTimeOffset FromUnixTimeMilliseconds(long milliseconds)
    {
        if (milliseconds < -62135596800000L || milliseconds > 253402300799999L)
        {
            throw new ArgumentOutOfRangeException("milliseconds", string.Format(Environment.GetResourceString("ArgumentOutOfRange_Range"), -62135596800000L, 253402300799999L));
        }
        long ticks = milliseconds * 10000L + 621355968000000000L;
        return new DateTimeOffset(ticks, TimeSpan.Zero);
    }
    // System.DateTimeOffset
    [__DynamicallyInvokable]
    public static DateTimeOffset FromUnixTimeSeconds(long seconds)
    {
    	if (seconds < -62135596800L || seconds > 253402300799L)
    	{
    		throw new ArgumentOutOfRangeException("seconds", string.Format(Environment.GetResourceString("ArgumentOutOfRange_Range"), -62135596800L, 253402300799L));
    	}
    	long ticks = seconds * 10000000L + 621355968000000000L;
    	return new DateTimeOffset(ticks, TimeSpan.Zero);
    }
    

      

    // System.DateTimeOffset
    [__DynamicallyInvokable]
    public long ToUnixTimeMilliseconds()
    {
        long num = this.UtcDateTime.Ticks / 10000L;
        return num - 62135596800000L;
    }
    // System.DateTimeOffset
    [__DynamicallyInvokable]
    public long ToUnixTimeSeconds()
    {
    	long num = this.UtcDateTime.Ticks / 10000000L;
    	return num - 62135596800L;
    }
    

      为了这四个方法特意装了VS2015,你没看错,是2015

  • 相关阅读:
    ubuntu分辨率
    xubuntu无法进图形界面问题
    dl简单模板,无pretraining过程
    ubuntu远程失败xrdp重启命令
    强制ubuntu登陆用户退出
    NumPy for MATLAB users
    How to calculate bits per character of a string? (bpc) to read
    ubuntu ssh前后台切换命令相关
    samba共享文件夹设置
    Ubuntu下环境变量的设置
  • 原文地址:https://www.cnblogs.com/binsys/p/4098363.html
Copyright © 2011-2022 走看看