Yuebon.NetCore/Yuebon.Commons/Extensions/DateTimeExtensions.cs
(开头部分) 10KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
/*******************************************************************************
* Copyright © 2017-2020 Yuebon.Framework 版权所有
* Author: Yuebon
* Description: Yuebon快速开发平台
* Website:http://www.yuebon.com
*********************************************************************************/
using System;
namespace Yuebon.Commons.Extensions
{
/// <summary>
/// 日期时间扩展
/// </summary>
public static class DateTimeExtensions
{
/// <summary>
///
/// </summary>
public static readonly DateTime BeginOfEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
/// <summary>
/// Converts a nullable date/time value to UTC.
/// </summary>
/// <param name="dateTime">The nullable date/time</param>
/// <returns>The nullable date/time in UTC</returns>
public static DateTime? ToUniversalTime(this DateTime? dateTime)
{
return dateTime.HasValue ? dateTime.Value.ToUniversalTime() : (DateTime?)null;
}
/// <summary>
/// Converts a nullable UTC date/time value to local time.
/// </summary>
/// <param name="dateTime">The nullable UTC date/time</param>
/// <returns>The nullable UTC date/time as local time</returns>
public static DateTime? ToLocalTime(this DateTime? dateTime)
{
return dateTime.HasValue ? dateTime.Value.ToLocalTime() : (DateTime?)null;
}
/// <summary>
/// Returns a date that is rounded to the next even hour above the given
/// date.
/// <p>
/// For example an input date with a time of 08:13:54 would result in a date
/// with the time of 09:00:00. If the date's time is in the 23rd hour, the
/// date's 'day' will be promoted, and the time will be set to 00:00:00.
/// </p>
/// </summary>
/// <param name="dateTime">the Date to round, if <see langword="null" /> the current time will
/// be used</param>
/// <returns>the new rounded date</returns>
public static DateTime GetEvenHourDate(this DateTime? dateTime)
{
if (!dateTime.HasValue)
{
dateTime = DateTime.UtcNow;
}
后面还有 218 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。