⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datetimeformatinfo.cls

📁 这是一个在vb下实现的各种加密程序,可以实现一般的文本加密和文件加密,但是很多算法都是已经被人破解过的.
💻 CLS
📖 第 1 页 / 共 4 页
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 1  'Persistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "DateTimeFormatInfo"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'    CopyRight (c) 2004 Kelly Ethridge
'
'    This file is part of VBCorLib.
'
'    VBCorLib is free software; you can redistribute it and/or modify
'    it under the terms of the GNU Library General Public License as published by
'    the Free Software Foundation; either version 2.1 of the License, or
'    (at your option) any later version.
'
'    VBCorLib is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU Library General Public License for more details.
'
'    You should have received a copy of the GNU Library General Public License
'    along with Foobar; if not, write to the Free Software
'    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
'
'    Module: DateTimeFormatInfo
'

''
' Provides a repository of formatting information to be used in formatting
' cDateTime and Date values to match that of a specific locale.
'
' @remarks Formatting dates can vary greatly across multiple cultures. Each
' culture can provide formatting information that is specific to itself. A DateTimeFormatInfo
' object contains all the formatting information necessary to create a wide range of formatted
' dates and times. Also, this class provides a Format method to allow for directly
' formatting dates and times.<br>
'
' @see DateTimeFormatInfoStatic
' @see ICloneable
' @see IFormatProvider
' @include "..\..\Includes\DateTimeFormatInfo.txt"
Option Explicit
Implements IObject
Implements ICloneable
Implements IFormatProvider

Private Const PROP_ABBREVIATEDDAYNAMES      As String = "AbbreviatedDayNames"
Private Const PROP_ABBREVIATEDMONTHNAMES    As String = "AbbreviatedMonthNames"
Private Const PROP_AMDESIGNATOR             As String = "AMDesignator"
Private Const PROP_DATESEPARATOR            As String = "DateSeparator"
Private Const PROP_DAYNAMES                 As String = "DayNames"
Private Const PROP_FIRSTDAYOFWEEK           As String = "FirstDayOfWeek"
Private Const PROP_FULLDATETIMEPATTERN      As String = "FullDateTimePattern"
Private Const PROP_LONGDATEPATTERN          As String = "LongDatePattern"
Private Const PROP_LONGTIMEPATTERN          As String = "LongTimePattern"
Private Const PROP_MONTHDAYPATTERN          As String = "MonthDayPattern"
Private Const PROP_MONTHNAMES               As String = "MonthNames"
Private Const PROP_PMDESIGNATOR             As String = "PMDesignator"
Private Const PROP_SHORTDATEPATTERN         As String = "ShortDatePattern"
Private Const PROP_SHORTTIMEPATTERN         As String = "ShortTimePattern"
Private Const PROP_TIMESEPARATOR            As String = "TimeSeparator"
Private Const PROP_YEARMONTHPATTERN         As String = "YearMonthPattern"
Private Const PROP_CALENDARWEEKRULE         As String = "CalendarWeekRule"
Private Const PROP_CALENDAR                 As String = "Calendar"
Private Const PROP_ISREADONLY               As String = "IsReadOnly"

Private Const C_RFC1123Pattern                      As String = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"
Private Const C_SORTABLEDATETIMEPATTERN             As String = "yyyy'-'MM'-'dd'T'HH':'mm':'ss"
Private Const C_UNIVERSALSORTABLEDATETIMEPATTERN    As String = "yyyy'-'MM'-'dd HH':'mm':'ss'Z'"



Private Type PropsType
    AbbreviatedDayNames()   As String
    AbbreviatedMonthNames() As String
    AMDesignator            As String
    DateSeparator           As String
    DayNames()              As String
    FirstDayOfWeek          As DayOfWeek
    FullDateTimePattern     As Variant
    LongDatePattern         As String
    LongTimePattern         As String
    MonthDayPattern         As String
    MonthNames()            As String
    PMDesignator            As String
    ShortDatePattern        As String
    ShortTimePattern        As String
    TimeSeparator           As String
    YearMonthPattern        As String
    AllLongDatePatterns()   As String
    AllLongTimePatterns()   As String
    AllShortDatePatterns()  As String
    AllShortTimePatterns()  As String
    AllMonthDayPatterns()   As String
    Calendar                As Calendar
    CalendarWeekRule        As CalendarWeekRule
    
    IsReadOnly              As Boolean
End Type

Private mProps      As PropsType
Private mLoaded     As Boolean
Private mPattern    As WordBuffer



''
' Returns the definition of the first week of the calendar year.
'
' @return A <b>CalendarWeekRule</b> value.
'
Public Property Get CalendarWeekRule() As CalendarWeekRule
    Call VerifyLoaded
    CalendarWeekRule = mProps.CalendarWeekRule
End Property

''
' Sets the definition of the first week for the calendar year.
'
' @param RHS A <b>CalendarWeekRule</b> value.
'
Public Property Let CalendarWeekRule(ByVal RHS As CalendarWeekRule)
    Call VerifyWritable
    Call VerifyLoaded
    mProps.CalendarWeekRule = RHS
End Property

''
' Returns the <b>Calendar</b> associated with this <b>DateTimeFormatInfo</b>.
'
' @return A calendar object.
' @remarks If no calendar is associated then a <b>GregorianCalendar</b> is returned.
'
Public Property Get Calendar() As Calendar
    If mProps.Calendar Is Nothing Then Set mProps.Calendar = New GregorianCalendar
    Set Calendar = mProps.Calendar
End Property

''
' Sets the calendar associated with this <b>DateTimeFormatInfo</b>.
'
' @param RHS The calendar to associate with this object.
'
Public Property Set Calendar(ByVal RHS As Calendar)
    Call VerifyWritable
    If RHS Is Nothing Then _
        Throw Cor.NewArgumentNullException("Calendar cannot be Nothing.", "Calendar")
    
    Set mProps.Calendar = RHS
End Property

''
' Returns an array of abbreviated weekday names.
'
' @return A string array containing the abbreviated weekday names.
'
Public Property Get AbbreviatedDayNames() As String()
    Call VerifyLoaded
    AbbreviatedDayNames = mProps.AbbreviatedDayNames
End Property

''
' Sets the weekday names to be used by this FormatProvider.
'
' @param RHS An array of weekday names to be uses as abbreviated weekday names.
' @remarks The array must contain exactly 7 days. If the DateTimeFormatInfo
' is ReadOnly then an exception will be thrown.
'
Public Property Let AbbreviatedDayNames(ByRef RHS() As String)
    Call AssignDayNames(RHS, mProps.AbbreviatedDayNames)
End Property

''
' Returns an array of names for all the months.
'
' @return The array of names for all of the months.
'
Public Property Get AbbreviatedMonthNames() As String()
    Call VerifyLoaded
    AbbreviatedMonthNames = mProps.AbbreviatedMonthNames
End Property

''
' Sets the abbreviated month names to be used by the formatter.
'
' @param RHS The array of month names to be used.
' @remarks There must be exactly 13 months. Some cultures have 13 months in the
' year. For those cultures that only have 12, and empty string as the 13 is all that is needed.<br>
' If the formatter is ReadOnly, an exception will be thrown.
'
Public Property Let AbbreviatedMonthNames(ByRef RHS() As String)
    Call AssignMonthNames(RHS, mProps.AbbreviatedMonthNames)
End Property

''
' Returns the string that is displayed for times from 12:00:00 AM to 11:59:59 AM.
'
' @return The AM designator. Generally 'AM' is used.
'
Public Property Get AMDesignator() As String
    Call VerifyLoaded
    AMDesignator = mProps.AMDesignator
End Property

''
' Sets the string that is display for times from 12:00:00 AM to 11:59:59 AM.
'
' @param RHS The new AM designator.
' @remarks If this formatter is ReadOnly, an exception will be thrown.
'
Public Property Let AMDesignator(ByRef RHS As String)
    Call VerifyWritable
    Call VerifyLoaded
    mProps.AMDesignator = RHS
End Property

''
' Returns the string that is displayed when separating the components of a date,
' such as year, month, day.
'
' @return The date separator string. Generally this is '/'.
'
Public Property Get DateSeparator() As String
    Call VerifyLoaded
    DateSeparator = mProps.DateSeparator
End Property

''
' Sets the string that is display when separating the components of a date,
' such as year, month, day.
'
' @param RHS The new date separator. Generally this is '/'.
' @remarks If this formatter is ReadOnly, an exception will be thrown.
'
Public Property Let DateSeparator(ByRef RHS As String)
    Call VerifyWritable
    Call VerifyLoaded
    mProps.DateSeparator = RHS
End Property

''
' Returns the names of the weekdays.
'
' @return An array containing the full names of the weekdays.
'
Public Property Get DayNames() As String()
    Call VerifyLoaded
    DayNames = mProps.DayNames
End Property

''
' Sets the names for the weekdays.
'
' @param RHS An array containing the weekday names to be used.
' @remarks There must be exactly 7 names. If this formatter is
' ReadOnly, an exception will be thrown.
'
Public Property Let DayNames(ByRef RHS() As String)
    Call VerifyWritable
    Call VerifyLoaded
    Call AssignDayNames(RHS, mProps.DayNames)
End Property

''
' Returns the first day of the week.
'
' @return The enum for the first day of the week.
' @remarks This DayOfWeek is 0 based, unlike VB's vbDayOfWeek which is 1 based.
'
Public Property Get FirstDayOfWeek() As DayOfWeek
    Call VerifyLoaded
    FirstDayOfWeek = mProps.FirstDayOfWeek
End Property

''
' Sets the first day of the week.
'
' @param RHS The enum for the first day of the week.
' @remarks If this formatter is ReadOnly, an exception is thrown.
'
Public Property Let FirstDayOfWeek(ByVal RHS As DayOfWeek)
    Call VerifyWritable
    Call VerifyLoaded
    mProps.FirstDayOfWeek = RHS
End Property

''
' Returns a formatting pattern that represents a full date and time associated
' with the 'F' formatting command.
'
' @return The full date and time pattern.
'
Public Property Get FullDateTimePattern() As String
    Call VerifyLoaded
    If IsEmpty(mProps.FullDateTimePattern) Then
        mProps.FullDateTimePattern = mProps.LongDatePattern & " " & mProps.LongTimePattern
    End If
    FullDateTimePattern = mProps.FullDateTimePattern
End Property

''
' Sets the formatting pattern used for a full date and time formatting,
' and is associated with the 'F' formatting command.
'
' @param RHS The new full date and time formatting pattern.
' @remark If this formatter is ReadOnly, an exception will be thrown.
'
Public Property Let FullDateTimePattern(ByRef RHS As String)
    Call VerifyWritable
    Call VerifyLoaded
    mProps.FullDateTimePattern = RHS
End Property

''

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -