StauffConsulting.Essentials.

DateUtils

C#: 
public abstract class DateUtils :
    object

VB: 
Public MustInherit Class DateUtils
    Inherits Object

Type Ancestry:  Object
+---DateUtils


Miscellaneous useful date/time related stuff.

Summary Info

Constructor Summary

DateUtils

Field Summary

static
readonly
string DateFormat The standard format string for dates.
static
readonly
string DateTimeFormat The standard format string for a combined date and time.
static
readonly
TimeUnit> InputUnitNames Names of units, both long and short (single unit values of TimeUnit only). Each name is lower case, plural.
static
readonly
TimeUnit, string> LongUnitNames Long names of units (single unit values of TimeUnit only). Each name is lower case, singular.
static
readonly
DateTime MaxDateTime The maximum valid date and time we allow in TouchWorks.
static
readonly
TimeUnit, string> MenuUnitNames Names of units for use in menus, radio buttons, etc. Each name is mixed case, singular, with an ampersand before the shortcut character.
static
readonly
DateTime MinDateTime The minimum valid date and time. DO NOT USE THIS VALUE TO REPRESENT A "NULL" DATETIME! Use NullDateTime instead.
static
readonly
DateTime NullDateTime This value, and no other, represents a "null" (blank, empty, unspecified) date/time.
static
readonly
TimeSpan NullTimeSpan This value, and no other, represents a "null" (blank, empty, unspecified) TimeSpan.
static
readonly
TimeUnit, string> ShortUnitNames Short names of units (single unit values of TimeUnit only). Each name is lower case, singular.
static
readonly
TimeUnit[] SingleTimeUnits The list of TimeUnit values that represent a single time unit, in descending order of size.
static
readonly
string TimeFormat The standard format string for times.

Property Summary

Method Summary

ConvertUnits Converts between TimeUnits.
CountUnits Returns the number of units specified in the given TimeUnits value; that is, the number of bits set in the enum.
CreateTimeSpan Creates a TimeSpan from the given values.
GetDateDiff
GetDateTokens Tokenizes an input string into three tokens (numbers or alphabetic names).
GetLongUnitNames Returns a list of the long unit names represented by the given TimeUnit value.
GetStandardDateString Converts a DateTime to a date string in our standard format.
GetStandardDateTimeString Converts a DateTime to a date and time string in our standard format.
IsSingle Returns whether the given TimeUnit value represents a single time unit.
LexUnitName Returns the TimeUnit value corresponding to the given input string. If no match is found, returns TimeUnit.None. If multiple matches are found, returns a TimeUnit with multiple bits set. Case is not significant, nor is leading/trailing whitespace.
ParseDate Converts a string to a date.
ParseDateTime Converts a string to a DateTime.
ParseDateTime
ParseTime Parses a string for a time.
ParseTime
ParseTimeSpan
ParseTimeSpan Parses a string into a TimeSpan.
TimeSpanToUnits Returns the total number of the given time units in the given TimeSpan.
ToString Converts a TimeSpan to a string, using the given units.
ToString Converts a TimeSpan to a string, using the given units.

Miscellany Summary

Constructor Details


DateUtils

C#: 
protected private DateUtils ()

VB: 
Protected Private Sub New()

Field Details


DateFormat

C#: 
readonly static string DateFormat;

VB: 
ReadOnly Shared DateFormat As String

The standard format string for dates.


DateTimeFormat

C#: 
readonly static string DateTimeFormat;

VB: 
ReadOnly Shared DateTimeFormat As String

The standard format string for a combined date and time.


InputUnitNames

C#: 
readonly static System.Collections.Generic.Dictionary InputUnitNames;

VB: 
ReadOnly Shared InputUnitNames As System.Collections.Generic.Dictionary(Of String, StauffConsulting.Essentials.TimeUnit)

Names of units, both long and short (single unit values of TimeUnit only). Each name is lower case, plural.


LongUnitNames

C#: 
readonly static System.Collections.Generic.Dictionary LongUnitNames;

VB: 
ReadOnly Shared LongUnitNames As System.Collections.Generic.Dictionary(Of StauffConsulting.Essentials.TimeUnit, String)

Long names of units (single unit values of TimeUnit only). Each name is lower case, singular.


MaxDateTime

C#: 
readonly static System.DateTime MaxDateTime;

VB: 
ReadOnly Shared MaxDateTime As Date

The maximum valid date and time we allow in TouchWorks. The current value was not chosen with a lot of care. The month and day should always be 12/31 because some range-checking code only checks the year.


MenuUnitNames

C#: 
readonly static System.Collections.Generic.Dictionary MenuUnitNames;

VB: 
ReadOnly Shared MenuUnitNames As System.Collections.Generic.Dictionary(Of StauffConsulting.Essentials.TimeUnit, String)

Names of units for use in menus, radio buttons, etc. Each name is mixed case, singular, with an ampersand before the shortcut character.


MinDateTime

C#: 
readonly static System.DateTime MinDateTime;

VB: 
ReadOnly Shared MinDateTime As Date

The minimum valid date and time. DO NOT USE THIS VALUE TO REPRESENT A "NULL" DATETIME! Use NullDateTime instead. It needs to be somewhat earlier than 1/1/1900, to allow for the small but real possibility of patients born before 1900. It also needs to be no less than 1/1/1753, which is the minimum date the database can handle. The month and day should always be 1/1 because some range-checking code only checks the year.


NullDateTime

C#: 
readonly static System.DateTime NullDateTime;

VB: 
ReadOnly Shared NullDateTime As Date

This value, and no other, represents a "null" (blank, empty, unspecified) date/time. Never compare this value using less than or greater than; only use equals (==) or not equals (!=). The actual value is subject to change without notice, though it will always collate before any legitimate DateTime value. The actual value is almost certainly not the value that gets stored in the database, which can vary from column to column.


NullTimeSpan

C#: 
readonly static System.TimeSpan NullTimeSpan;

VB: 
ReadOnly Shared NullTimeSpan As System.TimeSpan

This value, and no other, represents a "null" (blank, empty, unspecified) TimeSpan. Never compare this value using less than or greater than; only use equals (==) or not equals (!=). The actual value is subject to change without notice, though it will always collate before any legitimate TimeSpan value. The actual value is almost certainly not the value that gets stored in the database, which can vary from column to column.


ShortUnitNames

C#: 
readonly static System.Collections.Generic.Dictionary ShortUnitNames;

VB: 
ReadOnly Shared ShortUnitNames As System.Collections.Generic.Dictionary(Of StauffConsulting.Essentials.TimeUnit, String)

Short names of units (single unit values of TimeUnit only). Each name is lower case, singular.


SingleTimeUnits

C#: 
readonly static StauffConsulting.Essentials.TimeUnit[] SingleTimeUnits;

VB: 
ReadOnly Shared SingleTimeUnits() As StauffConsulting.Essentials.TimeUnit

The list of TimeUnit values that represent a single time unit, in descending order of size.


TimeFormat

C#: 
readonly static string TimeFormat;

VB: 
ReadOnly Shared TimeFormat As String

The standard format string for times.

Method Details


ConvertUnits

C#: 
static Decimal ConvertUnits(decimal value,
    StauffConsulting.Essentials.TimeUnit oldUnits,
    StauffConsulting.Essentials.TimeUnit newUnits)

VB: 
Shared Function ConvertUnits(ByVal value As Decimal, ByVal oldUnits As StauffConsulting.Essentials.TimeUnit, ByVal newUnits As StauffConsulting.Essentials.TimeUnit) As [Decimal]

Converts between TimeUnits. Conversions between week, day, hour, minute, and second are exact. Conversions between month and year are exact. Other conversions are based on 1 year = 365.25 days, and 1 month = 1/12 year.

Parameters

value   the value to be converted
oldUnits   the units to be converted from
newUnits   the units to be converted to
RETURNS   the new value


CountUnits

C#: 
static Int32 CountUnits(StauffConsulting.Essentials.TimeUnit units)

VB: 
Shared Function CountUnits(ByVal units As StauffConsulting.Essentials.TimeUnit) As Int32

Returns the number of units specified in the given TimeUnits value; that is, the number of bits set in the enum.

Parameters

units  


CreateTimeSpan

C#: 
static TimeSpan CreateTimeSpan(double value,
    StauffConsulting.Essentials.TimeUnit units)

VB: 
Shared Function CreateTimeSpan(ByVal value As Double, ByVal units As StauffConsulting.Essentials.TimeUnit) As TimeSpan

Creates a TimeSpan from the given values.

Parameters

value  
units  


GetDateDiff

C#: 
static Double GetDateDiff(StauffConsulting.Essentials.DateUtils.CompareFormat format,
    System.DateTime StartDate,
    System.DateTime EndDate)

VB: 
Shared Function GetDateDiff(ByVal format As StauffConsulting.Essentials.DateUtils.CompareFormat, ByVal StartDate As Date, ByVal EndDate As Date) As [Double]

Parameters

format  
StartDate  
EndDate  


GetDateTokens

C#: 
static String[] GetDateTokens(string input)

VB: 
Shared Function GetDateTokens(ByVal input As String) As [String]()

Tokenizes an input string into three tokens (numbers or alphabetic names). This method ensures correct separator syntax, and assumes that the input string contains only a date (no time), possibly with leading and/or trailing whitespace.

Parameters

input  


GetLongUnitNames

C#: 
static List<> GetLongUnitNames(StauffConsulting.Essentials.TimeUnit units)

VB: 
Shared Function GetLongUnitNames(ByVal units As StauffConsulting.Essentials.TimeUnit) As List(Of )

Returns a list of the long unit names represented by the given TimeUnit value.

Parameters

units  


GetStandardDateString

C#: 
static String GetStandardDateString(System.DateTime oDateTime)

VB: 
Shared Function GetStandardDateString(ByVal oDateTime As Date) As [String]

Converts a DateTime to a date string in our standard format.

Parameters

oDateTime  


GetStandardDateTimeString

C#: 
static String GetStandardDateTimeString(System.DateTime oDateTime)

VB: 
Shared Function GetStandardDateTimeString(ByVal oDateTime As Date) As [String]

Converts a DateTime to a date and time string in our standard format.

Parameters

oDateTime  


IsSingle

C#: 
static Boolean IsSingle(StauffConsulting.Essentials.TimeUnit unit)

VB: 
Shared Function IsSingle(ByVal unit As StauffConsulting.Essentials.TimeUnit) As [Boolean]

Returns whether the given TimeUnit value represents a single time unit.

Parameters

unit  


LexUnitName

C#: 
static TimeUnit LexUnitName(string input)

VB: 
Shared Function LexUnitName(ByVal input As String) As TimeUnit

Returns the TimeUnit value corresponding to the given input string. If no match is found, returns TimeUnit.None. If multiple matches are found, returns a TimeUnit with multiple bits set. Case is not significant, nor is leading/trailing whitespace.

Parameters

input  


ParseDate

C#: 
static DateTime ParseDate(string input)

VB: 
Shared Function ParseDate(ByVal input As String) As DateTime

Converts a string to a date. The string is assumed to contain only a time, with optional leading and trailing whitespace. This method recognizes a wide variety of date formats; it accepts pretty much anything that isn't ambiguous. Years must be given as 4 digits. If the day is greater than 12, the month may be given by number. Months may be specified by any unambiguous abbreviation. Components may be delimited by spaces, hyphens, or forward slashes, but the same delimiter must be used consistently. Year, month and day may appear in any order.

Parameters

input  


ParseDateTime

C#: 
static DateTime ParseDateTime(string input)

VB: 
Shared Function ParseDateTime(ByVal input As String) As DateTime

Converts a string to a DateTime. The date and time may appear in either order. For details about the time format, see ParseTime. For details about the date format, see ParseDate.

Parameters

input   the input string, containing both a date and a time
RETURNS   the date and time, or NullDateTime if the string contained spaces or nothing


ParseDateTime

C#: 
static DateTime ParseDateTime(string input,
    System.Boolean& hasDate,
    System.Boolean& hasTime)

VB: 
Shared Function ParseDateTime(ByVal input As String, ByVal hasDate As System.Boolean&, ByVal hasTime As System.Boolean&) As DateTime

Parameters

input  
hasDate  
hasTime  


ParseTime

C#: 
static DateTime ParseTime(string input)

VB: 
Shared Function ParseTime(ByVal input As String) As DateTime

Parses a string for a time. The string is assumed to contain only a time, with optional leading and trailing whitespace. Hours 1-12 are assumed to be AM if AM/PM is not specified. Hours 13-23 and 0 are allowed if AM/PM is not specified. Seconds are optional. Leading zeros are optional. Whitespace may optionally precede the AM/PM>

Parameters

input  


ParseTime

C#: 
static Boolean ParseTime(System.String& inputParam,
    System.DateTime& output)

VB: 
Shared Function ParseTime(ByVal inputParam As System.String&, ByVal output As System.DateTime&) As [Boolean]

Parameters

inputParam  
output  


ParseTimeSpan

C#: 
static TimeSpan ParseTimeSpan(string input,
    StauffConsulting.Essentials.TimeUnit& foundUnits)

VB: 
Shared Function ParseTimeSpan(ByVal input As String, ByVal foundUnits As StauffConsulting.Essentials.TimeUnit&) As TimeSpan

Parameters

input  
foundUnits  


ParseTimeSpan

C#: 
static TimeSpan ParseTimeSpan(string input)

VB: 
Shared Function ParseTimeSpan(ByVal input As String) As TimeSpan

Parses a string into a TimeSpan. See the other ParseTimeSpan for more details.

Parameters

input  


TimeSpanToUnits

C#: 
static Double TimeSpanToUnits(System.TimeSpan timeSpan,
    StauffConsulting.Essentials.TimeUnit units)

VB: 
Shared Function TimeSpanToUnits(ByVal timeSpan As System.TimeSpan, ByVal units As StauffConsulting.Essentials.TimeUnit) As [Double]

Returns the total number of the given time units in the given TimeSpan.

Parameters

timeSpan  
units  


ToString

C#: 
static String ToString(System.TimeSpan timeSpan,
    StauffConsulting.Essentials.TimeUnit units)

VB: 
Shared Function ToString(ByVal timeSpan As System.TimeSpan, ByVal units As StauffConsulting.Essentials.TimeUnit) As [String]

Converts a TimeSpan to a string, using the given units.

Parameters

timeSpan   the value to be converted to a string
units   the units to be used (possibly more than one unit)


ToString

C#: 
static String ToString(System.TimeSpan timeSpan,
    StauffConsulting.Essentials.TimeUnit units,
    string format)

VB: 
Shared Function ToString(ByVal timeSpan As System.TimeSpan, ByVal units As StauffConsulting.Essentials.TimeUnit, ByVal format As String) As [String]

Converts a TimeSpan to a string, using the given units. All possible TimeUnit values are supported, except for TimeUnit.None, which is only allowed for values of TimeSpan.Zero or NullTimeSpan. A timespan of Zero gives a string of "0", without units. NullTimeSpan gives an empty string.

Parameters

timeSpan   the value to be converted to a string
units   the units to be used
format   Optional format string, or null. The syntax depends on the units specified. For a single unit, the format string is passed to double.ToString().


generated by DocGenDotNet on 18 Nov 2008 6:35:01 PM