C# Class DevUtils.DateTimeExtensions.DateExtensions

Convert values to date
Exibir arquivo Open project: jornfilho/.net-Dev-Utils

Public Methods

Method Description
FromUnixTimestamp ( this unixTimestap ) : System.DateTime

Convert unix timestamp to date

GetWeekNumber ( this date ) : int

Get the week number of a date

Use BaseDateTimeExtensions.GetDefaultCalendarRule() as default calendar rule

Use BaseDateTimeExtensions.GetDefaultFirstWeekDay() as first week day

GetWeekNumber ( this date, CalendarWeekRule weekRule ) : int

Get the week number of a date

Use BaseDateTimeExtensions.GetDefaultFirstWeekDay() as first week day

GetWeekNumber ( this date, CalendarWeekRule weekRule, DayOfWeek firstWeekDay ) : int

Get the week number of a date

GetWeekNumber ( this date, DayOfWeek firstWeekDay ) : int

Get the week number of a date

Use BaseDateTimeExtensions.GetDefaultCalendarRule() as default calendar rule

IsValidDate ( this strValue ) : bool

Test if string value is a valid date value

IsValidDate ( this strValue, CultureInfo culture, DateTimeStyles dateTimeStyle ) : bool

Test if string value is a valid date value

SetAsUtc ( this date ) : System.DateTime

Convert date local to utc

Only change date local, don`t convert date and time

ToTimezoneDate ( this date, TimeZoneInfo destinationTimeZoneInfo ) : System.DateTime

Convert date to an especific timezone

ToTimezoneDate ( this date, TimeZoneInfo currentTimeZoneInfo, TimeZoneInfo destinationTimeZoneInfo ) : System.DateTime

Convert date to an especific timezone

ToTimezoneDate ( this date, TimeZoneInfo currentTimezoneInfo, string destinationTimeZoneName ) : System.DateTime

Convert date to an especific timezone

ToTimezoneDate ( this date, string destinationTimeZoneName ) : System.DateTime

Convert date to an especific timezone

ToTimezoneDate ( this date, string currentTimeZoneName, TimeZoneInfo destinationTimeZoneInfo ) : System.DateTime

Convert date to an especific timezone

ToTimezoneDate ( this date, string currentTimeZoneName, string destinationTimeZoneName ) : System.DateTime

Convert date to an especific timezone

ToUnixTimestamp ( this date ) : long

Convert date to unix timestamp

ToUnixTimestamp ( this date, TimeZoneInfo timezoneInfo ) : long

Convert date to unix timestamp

ToUnixTimestamp ( this date, string timezoneName ) : long

Convert date to unix timestamp

ToUtc ( this date ) : System.DateTime

Convert date to UtcDate

ToUtc ( this date, TimeZoneInfo timezoneInfo ) : System.DateTime

Convert date to UtcDate

ToUtc ( this date, string timezoneName ) : System.DateTime

Convert date to UtcDate

TryParseDate ( this strValue ) : System.DateTime

Convert string date to datetime

Return BaseDateTimeExtensions.GetCurrentDateTime() on error

TryParseDate ( this strValue, CultureInfo culture, DateTimeStyles dateTimeStyle ) : System.DateTime

Convert string date to datetime

Return BaseDateTimeExtensions.GetCurrentDateTime() on error

TryParseDate ( this strValue, System.DateTime defaultValue ) : System.DateTime

Convert string date to datetime

TryParseDate ( this strValue, System.DateTime defaultValue, CultureInfo culture, DateTimeStyles dateTimeStyle ) : System.DateTime

Convert string date to datetime

Method Details

FromUnixTimestamp() public static method

Convert unix timestamp to date
public static FromUnixTimestamp ( this unixTimestap ) : System.DateTime
unixTimestap this unix to convert
return System.DateTime

GetWeekNumber() public static method

Get the week number of a date

Use BaseDateTimeExtensions.GetDefaultCalendarRule() as default calendar rule

Use BaseDateTimeExtensions.GetDefaultFirstWeekDay() as first week day

public static GetWeekNumber ( this date ) : int
date this Date to get week number
return int

GetWeekNumber() public static method

Get the week number of a date

Use BaseDateTimeExtensions.GetDefaultFirstWeekDay() as first week day

public static GetWeekNumber ( this date, CalendarWeekRule weekRule ) : int
date this Date to get week number
weekRule CalendarWeekRule Rule to calculate week number
return int

GetWeekNumber() public static method

Get the week number of a date
public static GetWeekNumber ( this date, CalendarWeekRule weekRule, DayOfWeek firstWeekDay ) : int
date this Date to get week number
weekRule CalendarWeekRule Rule to calculate week number
firstWeekDay DayOfWeek First day of week
return int

GetWeekNumber() public static method

Get the week number of a date

Use BaseDateTimeExtensions.GetDefaultCalendarRule() as default calendar rule

public static GetWeekNumber ( this date, DayOfWeek firstWeekDay ) : int
date this Date to get week number
firstWeekDay DayOfWeek First day of week
return int

IsValidDate() public static method

Test if string value is a valid date value
public static IsValidDate ( this strValue ) : bool
strValue this string value
return bool

IsValidDate() public static method

Test if string value is a valid date value
public static IsValidDate ( this strValue, CultureInfo culture, DateTimeStyles dateTimeStyle ) : bool
strValue this string value
culture System.Globalization.CultureInfo culture origin
dateTimeStyle DateTimeStyles date style to convert
return bool

SetAsUtc() public static method

Convert date local to utc

Only change date local, don`t convert date and time

public static SetAsUtc ( this date ) : System.DateTime
date this Date to set local
return System.DateTime

ToTimezoneDate() public static method

Convert date to an especific timezone
public static ToTimezoneDate ( this date, TimeZoneInfo destinationTimeZoneInfo ) : System.DateTime
date this date to convert
destinationTimeZoneInfo System.TimeZoneInfo destination date timezone info
return System.DateTime

ToTimezoneDate() public static method

Convert date to an especific timezone
public static ToTimezoneDate ( this date, TimeZoneInfo currentTimeZoneInfo, TimeZoneInfo destinationTimeZoneInfo ) : System.DateTime
date this date to convert
currentTimeZoneInfo System.TimeZoneInfo current date timezone info
destinationTimeZoneInfo System.TimeZoneInfo destination date timezone info
return System.DateTime

ToTimezoneDate() public static method

Convert date to an especific timezone
public static ToTimezoneDate ( this date, TimeZoneInfo currentTimezoneInfo, string destinationTimeZoneName ) : System.DateTime
date this date to convert
currentTimezoneInfo System.TimeZoneInfo current date timezone info
destinationTimeZoneName string destination date timezone name
return System.DateTime

ToTimezoneDate() public static method

Convert date to an especific timezone
public static ToTimezoneDate ( this date, string destinationTimeZoneName ) : System.DateTime
date this date to convert
destinationTimeZoneName string destination date timezone name
return System.DateTime

ToTimezoneDate() public static method

Convert date to an especific timezone
public static ToTimezoneDate ( this date, string currentTimeZoneName, TimeZoneInfo destinationTimeZoneInfo ) : System.DateTime
date this date to convert
currentTimeZoneName string current date timezone name
destinationTimeZoneInfo System.TimeZoneInfo destination date timezone info
return System.DateTime

ToTimezoneDate() public static method

Convert date to an especific timezone
public static ToTimezoneDate ( this date, string currentTimeZoneName, string destinationTimeZoneName ) : System.DateTime
date this date to convert
currentTimeZoneName string current date timezone name
destinationTimeZoneName string destination date timezone name
return System.DateTime

ToUnixTimestamp() public static method

Convert date to unix timestamp
public static ToUnixTimestamp ( this date ) : long
date this date to convert
return long

ToUnixTimestamp() public static method

Convert date to unix timestamp
public static ToUnixTimestamp ( this date, TimeZoneInfo timezoneInfo ) : long
date this date to convert
timezoneInfo System.TimeZoneInfo current date timezone info
return long

ToUnixTimestamp() public static method

Convert date to unix timestamp
public static ToUnixTimestamp ( this date, string timezoneName ) : long
date this date to convert
timezoneName string current date timezone name
return long

ToUtc() public static method

Convert date to UtcDate
public static ToUtc ( this date ) : System.DateTime
date this date to convert
return System.DateTime

ToUtc() public static method

Convert date to UtcDate
public static ToUtc ( this date, TimeZoneInfo timezoneInfo ) : System.DateTime
date this date to convert
timezoneInfo System.TimeZoneInfo current date timezone info
return System.DateTime

ToUtc() public static method

Convert date to UtcDate
public static ToUtc ( this date, string timezoneName ) : System.DateTime
date this date to convert
timezoneName string current date timezone name
return System.DateTime

TryParseDate() public static method

Convert string date to datetime

Return BaseDateTimeExtensions.GetCurrentDateTime() on error

public static TryParseDate ( this strValue ) : System.DateTime
strValue this string to convert
return System.DateTime

TryParseDate() public static method

Convert string date to datetime

Return BaseDateTimeExtensions.GetCurrentDateTime() on error

public static TryParseDate ( this strValue, CultureInfo culture, DateTimeStyles dateTimeStyle ) : System.DateTime
strValue this string to convert
culture System.Globalization.CultureInfo date culture
dateTimeStyle DateTimeStyles datetime style
return System.DateTime

TryParseDate() public static method

Convert string date to datetime

public static TryParseDate ( this strValue, System.DateTime defaultValue ) : System.DateTime
strValue this string to convert
defaultValue System.DateTime default value when invalid date
return System.DateTime

TryParseDate() public static method

Convert string date to datetime
public static TryParseDate ( this strValue, System.DateTime defaultValue, CultureInfo culture, DateTimeStyles dateTimeStyle ) : System.DateTime
strValue this string to convert
defaultValue System.DateTime default value when invalid date
culture System.Globalization.CultureInfo date culture
dateTimeStyle DateTimeStyles datetime style
return System.DateTime