Ignore:
Timestamp:
Jan 31, 2007, 10:04:14 PM (18 years ago)
Author:
OverTaker
Message:

ToUniversalTimeメソッド追加。Monthのバグ修正。etc...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Include/Classes/System/DateTime.ab

    r73 r81  
    1313    Sub DateTime(ticks As Int64)
    1414        Ticks = ticks
    15         Kind = DateTimeKind.Unspecified
     15        Kind = Unspecified
    1616    End Sub
    1717
     
    5454    End Sub
    5555
    56     Sub DateTime(year As Long, month As Long, day As Long, hour As Long, minute As Long, second As Long, kind As DateTimeKind)
     56/*  Sub DateTime(year As Long, month As Long, day As Long, hour As Long, minute As Long, second As Long, kind As DateTimeKind)
    5757        DateTime(year, month, day, hour, minute, second)
    5858        Kind = kind
    59     End Sub
     59    End Sub*/
    6060
    6161    Sub DateTime(year As Long, month As Long, day As Long, hour As Long, minute As Long, second As Long, millisecond As Long)
     
    166166        For i = 1 To 12
    167167            day -= DaysInMonth(year, i)
    168             If day < 0 Then Return i
     168            If day <= 0 Then Return i
    169169        Next
    170170        Return 12
     
    177177    End Function
    178178
    179     Function DayOfWeek() As Long
     179    Function DayOfWeek() As DayOfWeek
    180180        Return totalDays() Mod 7 - 1
    181181    End Function
    182182
    183     Function Kind() As Long
     183    Function Kind() As DateTimeKind
    184184        Return kindFromBinary(m_Date)
    185185    End Function
     
    199199        Dim time As SYSTEMTIME
    200200        GetLocalTime(time)
    201         Dim date As DateTime(time, DateTimeKind.Local)
     201        Dim date As DateTime(time, Local)
    202202        Return date
    203203    End Function
     
    206206        Dim time As SYSTEMTIME
    207207        GetLocalTime(time)
    208         Dim date As DateTime(time.wYear, time.wMonth, time.wDay, DateTimeKind.Local)
     208        Dim date As DateTime(time.wYear, time.wMonth, time.wDay, Local)
    209209        Return date
    210210    End Function
     
    213213        Dim time As SYSTEMTIME
    214214        GetSystemTime(time)
    215         Dim date As DateTime(time, DateTimeKind.Utc)
     215        Dim date As DateTime(time, Utc)
    216216        Return date
    217217    End Function
     
    345345        Dim time As SYSTEMTIME
    346346        With time
    347             .wYear = Year
    348             .wMonth = Month
    349             .wDay = Day
    350             .wHour = Hour
    351             .wMinute = Minute
    352             .wSecond = Second
    353             .wMilliseconds = Millisecond
    354             .wDayOfWeek = DayOfWeek()
     347            .wYear = Year As Word
     348            .wMonth = Month As Word
     349            .wDay = Day As Word
     350            .wHour = Hour As Word
     351            .wMinute = Minute As Word
     352            .wSecond = Second As Word
     353            .wMilliseconds = Millisecond As Word
     354            .wDayOfWeek = DayOfWeek() As Word
    355355        End With
    356356
     
    388388        Dim time As SYSTEMTIME
    389389        FileTimeToSystemTime(localTime, time)
    390         Dim date As DateTime(time, DateTimeKind.Local)
     390        Dim date As DateTime(time, Local)
    391391        Return date
    392392    End Function
     
    411411        Dim time As SYSTEMTIME
    412412        FileTimeToSystemTime(fileTime, time)
    413         Dim date As DateTime(time, DateTimeKind.Utc)
     413        Dim date As DateTime(time, Utc)
    414414        Return date
    415415    End Function
     
    427427
    428428    Function ToLocalTime() As DateTime
    429         ToLocalTime = DateTime.FromFileTime(ToFileTimeUtc())
    430         ToLocalTime.Kind = DateTimeKind.Local
     429        If Kind = Utc Then
     430            ToLocalTime = DateTime.FromFileTime(ToFileTimeUtc())
     431            ToLocalTime.Kind = Local
     432        Else
     433            ToLocalTime = This
     434        End If
     435    End Function
     436
     437    Function ToUniversalTime() As DateTime
     438        If Kind = Local Then
     439            ToUniversalTime = DateTime.FromFileTimeUtc(ToFileTimeUtc())
     440            ToUniversalTime.Kind = Utc
     441        Else
     442            ToUniversalTime = This
     443        End If
    431444    End Function
    432445Private
     
    452465        dateData = (dateData >> 62) And &H03
    453466        If dateData = &H01 Then
    454             Return DateTimeKind.Local
     467            Return Local
    455468        ElseIf dateData = &H02 Then
    456             Return DateTimeKind.Unspecified
     469            Return Unspecified
    457470        ElseIf dateData = &H03 Then
    458             Return DateTimeKind.Utc
     471            Return Utc
    459472        End If
    460473    End Function
    461474End Class
    462475
    463 Enum DateTimeKind
     476Const Enum DateTimeKind
    464477    Local
    465478    Unspecified
     
    467480End Enum
    468481
    469 Enum DayOfWeek
     482Const Enum DayOfWeek
    470483    Sunday = 0
    471484    Monday
Note: See TracChangeset for help on using the changeset viewer.