Skip to content

Class DateTimeExtension ​

Namespace: Tool
Assembly: Tool.Net.dll

对DateTime进行升级

csharp
public static class DateTimeExtension

Inheritance ​

object ← DateTimeExtension

Inherited Members ​

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Extension Methods ​

ObjectExtension.Add<T>(object, object, object), ObjectExtension.CopyEntity(object, object, params string[]), ObjectExtension.EntityToJson(object), ObjectExtension.EntityToJson(object, bool), ObjectExtension.EntityToJson(object, bool, string), DictionaryExtension.GetDictionary(object), TypeExtension.GetFieldKey(object, string, out bool), TypeExtension.GetFieldKey<T>(object, string, out bool), TypeExtension.GetFieldKey(object, Type, string, out bool), ObjectExtension.GetIntPtr(object), ObjectExtension.GetIntPtrInt(object), TypeExtension.GetPropertieFind(object, string, bool), TypeExtension.GetProperties(object), TypeExtension.GetPropertyKey(object, string, out bool), TypeExtension.GetPropertyKey<T>(object, string, out bool), TypeExtension.GetPropertyKey(object, Type, string, out bool), TypeExtension.GetValue(object, PropertyDescriptor), TypeExtension.GetValue(object, string, bool), TypeExtension.GetValue(object, string), ObjectExtension.Read<T>(object, object, int, int), ObjectExtension.Read<T>(object, int, object, int, int), DictionaryExtension.SetDictionary(object, IDictionary<string, object>), TypeExtension.SetFieldKey(object, string, object), TypeExtension.SetFieldKey<T>(object, string, object), TypeExtension.SetFieldKey(object, Type, string, object), TypeExtension.SetPropertyKey(object, string, object), TypeExtension.SetPropertyKey<T>(object, string, object), TypeExtension.SetPropertyKey(object, Type, string, object), TypeExtension.SetValue(object, PropertyDescriptor, object), TypeExtension.SetValue(object, string, object, bool), TypeExtension.SetValue(object, string, object), ObjectExtension.ToBase64String(object), ObjectExtension.ToBytes(object), ObjectExtension.ToBytes(object, out Type), DictionaryExtension.ToDictionary(object), DictionaryExtension.ToDictionary<T>(object), DictionaryExtension.ToIDictionary(object), DictionaryExtension.ToIDictionary<T>(object), ObjectExtension.ToJson(object), ObjectExtension.ToJson(object, JsonSerializerOptions), ObjectExtension.ToJsonWeb(object), ObjectExtension.ToJsonWeb(object, Action<JsonSerializerOptions>), ObjectExtension.ToTryVar<T>(object, T), ObjectExtension.ToVar<T>(object), ObjectExtension.ToVar(object, Type, bool), ObjectExtension.ToVar(object, string), ObjectExtension.ToXml(object)

Remarks ​

代码由逆血提供支持

Methods ​

Add(DateTime[], DateTime) ​

给数组加新的值

csharp
public static DateTime[] Add(this DateTime[] txt, DateTime txt1)

Parameters ​

txt DateTime[]

DateTime[]

txt1 DateTime

新增的值

Returns ​

DateTime[]

Contains(DateTime[], DateTime) ​

查找该char数组中是否存在该值。

csharp
public static bool Contains(this DateTime[] txt, DateTime txt1)

Parameters ​

txt DateTime[]

DateTime[]

txt1 DateTime

查找的字符

Returns ​

bool

方法存在或不存在

DateMonday(DateTime, DayOfWeek) ​

返回当前日期指定的星期几

csharp
public static DateTime DateMonday(this DateTime dateTime, DayOfWeek Week)

Parameters ​

dateTime DateTime

DateTime

Week DayOfWeek

指定星期几

Returns ​

DateTime

返回当前日期指定的星期几

GetArrayIndex(DateTime[], int, int) ​

同于获取指定部分的内容

csharp
public static DateTime[] GetArrayIndex(this DateTime[] obj, int index, int count)

Parameters ​

obj DateTime[]

对象数组

index int

从下标N开始

count int

到下标N结束

Returns ​

DateTime[]

返回一部分的数组内容

GetDaysOfMonth(DateTime) ​

本月有多少天

csharp
public static int GetDaysOfMonth(this DateTime dt)

Parameters ​

dt DateTime

日期

Returns ​

int

天数

GetDaysOfYear(DateTime) ​

本年有多少天

csharp
public static int GetDaysOfYear(this DateTime idt)

Parameters ​

idt DateTime

日期

Returns ​

int

本天在当年的天数

GetMilliseconds(DateTime) ​

根据实力,计算与当前时间的毫秒差

csharp
public static double GetMilliseconds(this DateTime dateTime)

Parameters ​

dateTime DateTime

DateTime

Returns ​

double

适用于获取代码执行时的耗时

GetWeekNameOfDay(DateTime) ​

返回当前日期的星期名称

csharp
public static string GetWeekNameOfDay(this DateTime idt)

Parameters ​

idt DateTime

日期

Returns ​

string

星期名称

GetWeekNumberOfDay(DateTime) ​

返回当前日期的星期编号

csharp
public static string GetWeekNumberOfDay(this DateTime idt)

Parameters ​

idt DateTime

日期

Returns ​

string

星期数字编号

ToLocalTime(double, bool) ​

返回 类型 ,根据指定时间数字转换

csharp
public static DateTime ToLocalTime(double Localtime, bool tal)

Parameters ​

Localtime double

指定的时间数字

tal bool

true 毫秒, false 秒。

Returns ​

DateTime

返回时间类型

ToLocalTime(DateTime, bool) ​

返回 类型 ,根据指定时间数字转换

csharp
public static long ToLocalTime(this DateTime dateTime, bool tal)

Parameters ​

dateTime DateTime

时间类型

tal bool

返回 true 毫秒, false 秒。

Returns ​

long

返回64位时间数字

基于Apache-2.0协议开源