📄 datetimeformatinfo.cls
字号:
' Returns if this formatter is ReadOnly.
'
' @return Indication if is ReadOnly or not.
'
Public Property Get IsReadOnly() As Boolean
IsReadOnly = mProps.IsReadOnly
End Property
' for internal use only.
Friend Property Let IsReadOnly(ByVal RHS As Boolean)
mProps.IsReadOnly = RHS
End Property
''
' Returns a pattern for formatting just the date portion and is
' associated with the 'D' formatting command.
'
' @return A date-only formatting.
'
Public Property Get LongDatePattern() As String
Call VerifyLoaded
LongDatePattern = mProps.LongDatePattern
End Property
''
' Sets a pattern used for formatting just the date portion and is
' associated with the 'D' formatting command.
'
' @param RHS The pattern used to format the date.
' @remarks If this formatter is ReadOnly, an exception is thrown.
'
Public Property Let LongDatePattern(ByRef RHS As String)
Call VerifyWritable
Call VerifyLoaded
mProps.LongDatePattern = RHS
mProps.FullDateTimePattern = Empty
End Property
''
' Returns a pattern used in formatting the time portion and is
' associated with the 'T' formatting command.
'
' @return The time-only formatting pattern.
'
Public Property Get LongTimePattern() As String
Call VerifyLoaded
LongTimePattern = mProps.LongTimePattern
End Property
''
' Sets the pattern used to format the time part when using the
' 'T' formatting command.
'
' @param RHS The new formatting pattern.
' @remarks If this formatter is ReadOnly, an exception is thrown.
'
Public Property Let LongTimePattern(ByRef RHS As String)
Call VerifyWritable
Call VerifyLoaded
mProps.LongTimePattern = RHS
mProps.FullDateTimePattern = Empty
End Property
''
' Returns the month/day pattern associated with either 'm' or 'M'
' formatting commands.
'
' @return The MonthDay formatting pattern.
'
Public Property Get MonthDayPattern() As String
Call VerifyLoaded
MonthDayPattern = mProps.MonthDayPattern
End Property
''
' Sets the month/day formatting pattern associated with either
' 'm' or 'M' formatting commands.
'
' @param RHS The new Month/Day pattern
' @remarks If this formatter is ReadOnly, an exception is thrown.
'
Public Property Let MonthDayPattern(ByRef RHS As String)
Call VerifyWritable
Call VerifyLoaded
mProps.MonthDayPattern = RHS
End Property
''
' Returns the full names for the months of the year.
'
' @return An array containing the full month names.
'
Public Property Get MonthNames() As String()
Call VerifyLoaded
MonthNames = mProps.MonthNames
End Property
''
' Sets the full month names to be used by the formatter.
'
' @param RHS The array of month names.
' @remarks There must be exactly 13 months. Some cultures have 13 months
' in a calendar year. If a culture only has 12 months, then 13th month is empty.
' If this formatter is ReadOnly, an exception is thrown.
'
Public Property Let MonthNames(ByRef RHS() As String)
Call AssignMonthNames(RHS, mProps.MonthNames)
End Property
''
' Returns the string diplayed for times between 12:00:00 PM and 12:00:00 AM.
'
' @return The current PM designator. Generally this is 'PM'.
'
Public Property Get PMDesignator() As String
Call VerifyLoaded
PMDesignator = mProps.PMDesignator
End Property
''
' Sets the string display for times between 12:00:00 PM and 12:00:00 AM.
'
' @param RHS The new PM designator. Generally this is 'PM'.
' @remarks If this formatter is ReadOnly, an exception is thrown.
'
Public Property Let PMDesignator(ByRef RHS As String)
Call VerifyWritable
Call VerifyLoaded
mProps.PMDesignator = RHS
End Property
''
' Returns the pattern as specified by RFC-1123 and associated with
' the 'r' or 'R' formatting commands.
'
' @return The RFC-1123 pattern <ddd, dd MMM yyyy HH':'mm':'ss 'GMT'>.
'
Public Property Get RFC1123Pattern() As String
RFC1123Pattern = C_RFC1123Pattern
End Property
''
' Returns the pattern for short date formatting associated with the 'd' formatting command.
'
' @return The formatting pattern for a short date.
'
Public Property Get ShortDatePattern() As String
Call VerifyLoaded
ShortDatePattern = mProps.ShortDatePattern
End Property
''
' Sets the pattern used in formatting dates with the 'd' formatting command.
'
' @param RHS The new short date formatting pattern.
' @remarks If this formatter is ReadOnly, an exception is thrown.
'
Public Property Let ShortDatePattern(ByRef RHS As String)
Call VerifyWritable
Call VerifyLoaded
mProps.ShortDatePattern = RHS
End Property
''
' Returns the formatting pattern for a short time using the 't' formatting command.
'
' @return The short time formatting pattern.
'
Public Property Get ShortTimePattern() As String
Call VerifyLoaded
ShortTimePattern = mProps.ShortTimePattern
End Property
''
' Sets the formatting pattern for a short time using the 't' formatting command.
'
' @param RHS The new short time formatting pattern.
' @remarks If this formatter is ReadOnly, an exception is thrown.
'
Public Property Let ShortTimePattern(ByRef RHS As String)
Call VerifyWritable
Call VerifyLoaded
mProps.ShortDatePattern = RHS
End Property
''
' Returns a pattern that can be used in string sorting to produce an
' ascending sort with string based dates and times. This pattern is
' associated with the 's' formatting command.
'
' @return The string sortable pattern <yyyy'-'MM'-'dd'T'HH':'mm':'ss>.
' @remarks This pattern is the same across all cultures.
'
Public Property Get SortableDateTimePattern() As String
SortableDateTimePattern = C_SORTABLEDATETIMEPATTERN
End Property
''
' Returns the separator of time components, such as hours, minutes, seconds.
'
' @return The time component separator.
'
Public Property Get TimeSeparator() As String
Call VerifyLoaded
TimeSeparator = mProps.TimeSeparator
End Property
''
' Set the separator for time components.
'
' @param RHS The new time component separator.
' @remarks If this formatter is ReadOnly, an exception is thrown.
'
Public Property Let TimeSeparator(ByRef RHS As String)
Call VerifyWritable
Call VerifyLoaded
mProps.TimeSeparator = RHS
End Property
''
' Returns a string sortable pattern that is associated with the 'u' or 'U'
' formatting commands.
'
' @return The UniversalSortableDateTimePattern <yyyy'-'MM'-'dd HH':'mm':'ss'Z'>.
' @remarks The pattern can be used to sort string representations of a date
' using the universal time designator "Z". This pattern is the same
' across all cultures.
'
Public Property Get UniversalSortableDateTimePattern() As String
UniversalSortableDateTimePattern = C_UNIVERSALSORTABLEDATETIMEPATTERN
End Property
''
' Returns the pattern representing a YearMonth combination. This is
' associated with the 'y' or 'Y' formatting commands.
'
' @return The YearMonth formatting pattern.
'
Public Property Get YearMonthPattern() As String
Call VerifyLoaded
YearMonthPattern = mProps.YearMonthPattern
End Property
''
' Sets the pattern that represents a YearMonth combination. This is
' associated with the 'y' or 'Y' formatting commands.
'
' @param RHS The new YearMonth formatting pattern.
' @remarks If this formatter is ReadOnly, an exception is thrown.
'
Public Property Let YearMonthPattern(ByRef RHS As String)
Call VerifyWritable
Call VerifyLoaded
mProps.YearMonthPattern = RHS
End Property
''
' Returns a clone of this instance. If this instance is ReadOnly,
' the clone will also be ReadOnly.
'
' @param The clones version of this instance.
'
Public Function Clone() As DateTimeFormatInfo
Set Clone = New DateTimeFormatInfo
Call Clone.CloneHelper(mProps)
End Function
''
' Returns the abbreviated name for the specified day-of-the-week.
'
' @param dow The Day-Of-Week to get the name of.
' @return The abbreviated version of the name for the day-of-week.
' @remarks DayOfWeek is 0 based. It is not identical to the vbDayOfweek,
' which is 1 based.
'
Public Function GetAbbreviatedDayName(ByVal dow As DayOfWeek) As String
Call VerifyLoaded
GetAbbreviatedDayName = mProps.AbbreviatedDayNames(dow)
End Function
''
' Returns the name of the Era specified.
'
' @param Era The era to retrieve the name for.
' @return The name of the era.
' @remarks Eras are identified by number. The gregorian calendar has two
' era, BC and AD. Only AD is recognized in this case by a number 1.
' <p>This feature is not fully implemented. It will only return 'AD'
' regardless of the culture.</p>
'
Public Function GetAbbreviatedEraName(ByVal Era As Long) As String
Call VerifyLoaded
Era = "AD"
End Function
''
' Retrieves the abbreviated name for a given month.
'
' @param Month The month number in the calendar starting at 1.
' @return The name of the specified month.
'
Public Function GetAbbreviatedMonthName(ByVal Month As Long) As String
Call VerifyLoaded
If Month < 1 Or Month > 13 Then _
Throw Cor.NewArgumentOutOfRangeException("Month must be between 1 and 13.", "Month", Month)
GetAbbreviatedMonthName = mProps.AbbreviatedMonthNames(Month - 1)
End Function
''
' Returns all of the patterns for a specified formatting command. Or if no command
' is specified, then all of the patterns are returned.
'
' @param Format The formatting command to retrieve all the patterns for.
' @return An array of all the requested formatting patterns.
'
Public Function GetAllDateTimePatterns(Optional ByRef Format As Variant) As String()
Call VerifyLoaded
If IsMissing(Format) Then
GetAllDateTimePatterns = CombineAllDateTimePatterns
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -