C# Class Shared.Helpers.DateTimeHelper

Show file Open project: sealuzh/PersonalAnalytics

Public Methods

Method Description
DateTimeFromJavascriptTimestamp ( long date ) : System.DateTime

C# DateTime from JavaScript Timestamp

GetFirstDayOfWeek_Iso8801 ( DateTimeOffset date ) : DateTimeOffset

For a given date, return the week's start date see: http://stackoverflow.com/questions/662379/calculate-date-from-week-number

GetLastDayOfWeek_Iso8801 ( DateTimeOffset date ) : DateTimeOffset

For a given date, return the week's last date

GetShortestDayName ( DateTimeOffset date ) : string

Returns the shortest day name for a given date according to the current culture

GetShortestDayName ( int dayNumber ) : string

Returns the shortest day name for a given week day number according to the current culture

GetWeekOfYear_Iso8601 ( System.DateTime time ) : int

This presumes that weeks start with Monday. Week 1 is the 1st week of the year with a Thursday in it. see: http://stackoverflow.com/questions/11154673/get-the-correct-week-number-of-a-given-date

JavascriptTimestampFromDateTime ( System.DateTime date ) : long

JavaScript Timestamp from C# DateTime

RoundUp ( System.DateTime dt, System.TimeSpan d ) : System.DateTime

Rounds up a time (e.g. 10minutes)

Method Details

DateTimeFromJavascriptTimestamp() public static method

C# DateTime from JavaScript Timestamp
public static DateTimeFromJavascriptTimestamp ( long date ) : System.DateTime
date long
return System.DateTime

GetFirstDayOfWeek_Iso8801() public static method

For a given date, return the week's start date see: http://stackoverflow.com/questions/662379/calculate-date-from-week-number
public static GetFirstDayOfWeek_Iso8801 ( DateTimeOffset date ) : DateTimeOffset
date DateTimeOffset
return DateTimeOffset

GetLastDayOfWeek_Iso8801() public static method

For a given date, return the week's last date
public static GetLastDayOfWeek_Iso8801 ( DateTimeOffset date ) : DateTimeOffset
date DateTimeOffset
return DateTimeOffset

GetShortestDayName() public static method

Returns the shortest day name for a given date according to the current culture
public static GetShortestDayName ( DateTimeOffset date ) : string
date DateTimeOffset
return string

GetShortestDayName() public static method

Returns the shortest day name for a given week day number according to the current culture
public static GetShortestDayName ( int dayNumber ) : string
dayNumber int
return string

GetWeekOfYear_Iso8601() public static method

This presumes that weeks start with Monday. Week 1 is the 1st week of the year with a Thursday in it. see: http://stackoverflow.com/questions/11154673/get-the-correct-week-number-of-a-given-date
public static GetWeekOfYear_Iso8601 ( System.DateTime time ) : int
time System.DateTime
return int

JavascriptTimestampFromDateTime() public static method

JavaScript Timestamp from C# DateTime
public static JavascriptTimestampFromDateTime ( System.DateTime date ) : long
date System.DateTime
return long

RoundUp() public static method

Rounds up a time (e.g. 10minutes)
public static RoundUp ( System.DateTime dt, System.TimeSpan d ) : System.DateTime
dt System.DateTime
d System.TimeSpan
return System.DateTime