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

📄 gregoriancalendar.cls

📁 这是一个在vb下实现的各种加密程序,可以实现一般的文本加密和文件加密,但是很多算法都是已经被人破解过的.
💻 CLS
📖 第 1 页 / 共 2 页
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 1  'Persistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "GregorianCalendar"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'    CopyRight (c) 2005 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: GregorianCalendar
'

''
' Provides methods for manipulating dates using the Gregorian calendar mathematics.
'
' @remarks The Gregorian calendar recognizes an era of BC (Before Christ) and
' AD (Anno Domino). The GregorianCalendar class only support the AD era (1).
' <p>The calendar supports the time from 01/01/0001 12:00:00AM to 12/31/9999 11:59:59PM.</p>
' <p>Only leap year is recognized and occurs every 4 years, except a year that is
' evenly divisible by 100. However, if it is divisible by 400 then it is a leap year.</p>
' <p>There are 12 months in the Gregorian calendar. The number of days range from 28 to
' 31, except on leap year when the shortest month is 29 days.</p>
'
' @see Calendar
' @see GregorianCalendarStatic
'
Option Explicit
Implements IObject
Implements Calendar


Public Enum GregorianCalendarTypes
    Localized = 1
    USEnglish = 2
    MiddleEastFrench = 9
    Arabic = 10
    TransliteratedEnglish = 11
    TransliteratedFrench = 12
End Enum


Private mCalendarType As GregorianCalendarTypes
Private mTwoDigitYearMax As Long



''
' Returns the calendar type that represents the language version.
'
' @return The calendar type that represents the language version.
' @remarks This value is only tracked with the calendar object. It
' does not apply languages to text values.
'
Public Property Get CalendarType() As GregorianCalendarTypes
    CalendarType = mCalendarType
End Property

''
' Sets the calendar type that represents the language version.
'
' @param RHS The calendar type to set this instance to.
' @remarks This value is only tracked with the calendar object. It
' does not apply languages to text values.
'
Public Property Let CalendarType(ByVal RHS As GregorianCalendarTypes)
    mCalendarType = RHS
End Property

''
' Returns an array of eras this calendar represents.
'
' @return An array containing the eras represented by this calendar.
' @remarks The Gregorian calendar recognizes only one era. The returned
' array will have one element containing the value 1.
'
Public Property Get Eras() As Long()
    Dim ret(0) As Long
    ret(0) = 1
    Eras = ret
End Property

''
' Returns the maximum year to be created from a 2-digit year.
'
' @return The maximum year to be created.
' @remarks The property allows a 2-digit year (0 to 99) to be converted to
' a 4-digit year(0001 to 9999). The 2-digit year of 99 does not necessarily
' corrispond to the largest year to be created. For example, for a maximum
' year of 2029, the value 99 would convert to 1999 and 0 would convert to 2000.
' The years 29 would become 2029 and 30 would become 1930.
'
Public Property Get TwoDigitYearMax() As Long
    TwoDigitYearMax = mTwoDigitYearMax
End Property

''
' Sets the maximum year to be created from a 2-digit year.
'
' @param RHS The new 4-digit year maximum a 2-digit year is converted to.
' @remarks The property allows a 2-digit year (0 to 99) to be converted to
' a 4-digit year(0001 to 9999). The 2-digit year of 99 does not necessarily
' corrispond to the largest year to be created. For example, for a maximum
' year of 2029, the value 99 would convert to 1999 and 0 would convert to 2000.
' The years 29 would become 2029 and 30 would become 1930.
'
Public Property Let TwoDigitYearMax(ByVal RHS As Long)
    If RHS < 100 Or RHS > 9999 Then _
        Throw Cor.NewArgumentOutOfRangeException("Year must be between 100 and 9999 inclusively.", "TwoDigitYearMax", RHS)
    
    mTwoDigitYearMax = RHS
End Property

''
' Adds a number of days to the date provided using Gregorian math.
'
' @param Time This is a Date or cDateTime object to add a number of days to.
' @param Days The number of days to be added to <i>Time</i>.
' @return A <b>cDateTime</b> object with the new date.
' @remarks Using this method works exactly like using the <b>AddDays</b>
' method on the <b>cDateTime</b> objects.
' <p>A new cDateTime object is returned with the days added to the
' original <i>Time</i>. If a Date is passed in, a cDateTime object is
' still returned.</p>
' <p>A negative value can be supplied for <i>Days</i>.</p>
'
Public Function AddDays(ByRef Time As Variant, ByVal Days As Long) As cDateTime
    Set AddDays = cDateTime.GetcDateTime(Time).AddDays(Days)
End Function

''
' Adds a number of hours to the date provided.
'
' @param Time A Date or cDateTime object to add a number of hours to.
' @param Hours The number of hours to be added to the time portion of a date.
' @return Returns a <b>cDateTime</b> with the specified number of hours added.
'
Public Function AddHours(ByRef Time As Variant, ByVal Hours As Long) As cDateTime
    Set AddHours = cDateTime.GetcDateTime(Time).AddHours(Hours)
End Function

''
' Returns a <b>cDateTime</b> this is the specified number of Milliseconds from the original Time.
'
' @param Time The time to add the specified number of Milliseconds to.
' @param Milliseconds The number of Milliseconds to be added to <i>Time</i>. This can be negative.
' @return Returns a <b>cDateTime</b> with the specified number of Milliseconds added.
'
Public Function AddMilliseconds(ByRef Time As Variant, ByVal Milliseconds As Double) As cDateTime
    Set AddMilliseconds = cDateTime.GetcDateTime(Time).AddMilliseconds(Milliseconds)
End Function

''
' Returns a <b>cDateTime</b> this is the specified number of Minutes from the original Time.
'
' @param Time The time to add the specified number of Minutes to.
' @param Minutes The number of Minutes to be added to <i>Time</i>. This can be negative.
' @return Returns a <b>cDateTime</b> with the specified number of Minutes added.
'
Public Function AddMinutes(ByRef Time As Variant, ByVal Minutes As Long) As cDateTime
    Set AddMinutes = cDateTime.GetcDateTime(Time).AddMinutes(Minutes)
End Function

''
' Returns a <b>cDateTime</b> this is the specified number of Months from the original Time.
'
' @param Time The time to add the specified number of Months to.
' @param Months The number of Months to be added to <i>Time</i>. This can be negative.
' @return Returns a <b>cDateTime</b> with the specified number of Months added.
'
Public Function AddMonths(ByRef Time As Variant, ByVal Months As Long) As cDateTime
    Set AddMonths = cDateTime.GetcDateTime(Time).AddMonths(Months)
End Function

''
' Returns a <b>cDateTime</b> this is the specified number of Seconds from the original Time.
'
' @param Time The time to add the specified number of Seconds to.
' @param Seconds The number of Seconds to be added to <i>Time</i>. This can be negative.
' @return Returns a <b>cDateTime</b> with the specified number of Seconds added.
'
Public Function AddSeconds(ByRef Time As Variant, ByVal Seconds As Long) As cDateTime
    Set AddSeconds = cDateTime.GetcDateTime(Time).AddSeconds(Seconds)
End Function

''
' Returns a <b>cDateTime</b> this is the specified number of Weeks from the original Time.
'
' @param Time The time to add the specified number of Weeks to.
' @param Weeks The number of Weeks to be added to <i>Time</i>. This can be negative.
' @return Returns a <b>cDateTime</b> with the specified number of Weeks added.
'
Public Function AddWeeks(ByRef Time As Variant, ByVal Weeks As Long) As cDateTime
    Set AddWeeks = AddDays(Time, Weeks * 7)
End Function

''
' Returns a <b>cDateTime</b> this is the specified number of Years from the original Time.
'
' @param Time The time to add the specified number of Years to.
' @param Years The number of Years to be added to <i>Time</i>. This can be negative.
' @return Returns a <b>cDateTime</b> with the specified number of Years added.
'
Public Function AddYears(ByRef Time As Variant, ByVal Years As Long) As cDateTime
    Set AddYears = cDateTime.GetcDateTime(Time).AddYears(Years)
End Function

''
' Returns the day of the months for the specified date.
'
' @param Time The date inwhich to retrieve the day of the month.
' @return The day of the month for the specified date.
'
Public Function GetDayOfMonth(ByRef Time As Variant) As Long
    GetDayOfMonth = cDateTime.GetcDateTime(Time).Day
End Function

''
' Returns the <b>DayOfWeek</b> enum of the specified date.
'
' @param Time The date to retrieve the day of the week for.
' @return A <b>DayOfWeek</b> enum representing the day of the week.
' @remarks The <b>DayOfWeek</b> is Sunday and is 0-based. The Visual Basic
' enum vbDayOfWeek is 1-based.
'
Public Function GetDayOfWeek(ByRef Time As Variant) As DayOfWeek
    GetDayOfWeek = cDateTime.GetcDateTime(Time).DayOfWeek
End Function

''
' Returns the day of the year for the specified date.
'
' @param Time The date to retrieve the day of the year from.
' @return The day of the year.
'
Public Function GetDayOfYear(ByRef Time As Variant) As Long
    GetDayOfYear = cDateTime.GetcDateTime(Time).DayOfYear
End Function

''
' Returns the number of days in the specified month.
'
' @param Year The year inwhich the month exists. This is used by calendars that
' have months that change based on the year, such as leap years.
' @param Month The month to retrieve the number of days of.
' @param Era The time period inwhich the year exists.
'
Public Function GetDaysInMonth(ByVal Year As Long, ByVal Month As Long, Optional ByRef Era As Variant) As Long
    Call VerifyEra(Era)
    GetDaysInMonth = cDateTime.DaysInMonth(Year, Month)
End Function

''
' Returns the number of days in the specified year.
'
' @param Year The year to retrieve the number of days of.
' @param Era The era the year exists in.
' @return The number of days in the year.
' @remarks The gregorian calendar has 365 days in a normal year
' and 366 days in a leap year.
'
Public Function GetDaysInYear(ByVal Year As Long, Optional ByRef Era As Variant) As Long
    Call VerifyEra(Era)
    If cDateTime.IsLeapYear(Year) Then
        GetDaysInYear = 366
    Else
        GetDaysInYear = 365
    End If
End Function

''
' Returns the era that the specified time exists in.
'
' @param Time The time to find the containing era of.
' @return The era for the time.
' @remarks The <b>GregorianCalendar</b> class only supports
' the current era of AD. This returns a constant of 1.
'
Public Function GetEra(ByRef Time As Variant) As Long
    Dim dt As cDateTime
    Set dt = cDateTime.GetcDateTime(Time)    ' verifies we have a date
    GetEra = 1
End Function

''
' Returns the hour of the specified time.
'
' @param Time The time to retrieve the hour from.
' @return The hour portion of the time.
'
Public Function GetHour(ByRef Time As Variant) As Long
    GetHour = cDateTime.GetcDateTime(Time).Hour
End Function

''
' Returns the milliseconds of the specified time.
'
' @param Time The time to retrieve the milliseconds from.
' @return The millisecond portion of the time.
'
Public Function GetMilliseconds(ByRef Time As Variant) As Double
    GetMilliseconds = cDateTime.GetcDateTime(Time).Millisecond
End Function

''
' Returns the minute of the specified time.
'
' @param Time The time to retrieve the minute from.
' @return The minute portion of the time.
'
Public Function GetMinute(ByRef Time As Variant) As Long
    GetMinute = cDateTime.GetcDateTime(Time).Minute
End Function

''
' Returns the month of the specified time.
'
' @param Time The time to retrieve the month from.
' @return The month portion of the time.
'
Public Function GetMonth(ByRef Time As Variant) As Long
    GetMonth = cDateTime.GetcDateTime(Time).Month
End Function

''
' Returns the number of months in the specified year.
'
' @param Year The year to get the number of months of.
' @param Era The era the year exists in.
' @return The number of months in the year.
' @remarks The Gregorian calendar has 12 months in a year.
'
Public Function GetMonthsInYear(ByVal Year As Long, Optional ByRef Era As Variant) As Long
    Call VerifyEra(Era)
    Call VerifyYear(Year)
    GetMonthsInYear = 12
End Function

''
' Returns the second of the specified time.

⌨️ 快捷键说明

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