Changeset 82


Ignore:
Timestamp:
Feb 1, 2007, 7:35:43 PM (18 years ago)
Author:
OverTaker
Message:

KindがUnspecifiedのとき、UTCとLocalの変換ができないバグを修正

File:
1 edited

Legend:

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

    r81 r82  
    385385    Static Function FromFileTime(fileTime As FILETIME) As DateTime
    386386        Dim localTime As FILETIME
     387        Dim time As SYSTEMTIME
    387388        FileTimeToLocalFileTime(fileTime, localTime)
    388         Dim time As SYSTEMTIME
    389389        FileTimeToSystemTime(localTime, time)
     390
    390391        Dim date As DateTime(time, Local)
    391392        Return date
     
    397398            .wYear = Year As Word
    398399            .wMonth = Month As Word
     400            .wDayOfWeek = DayOfWeek As Word
    399401            .wDay = Day As Word
    400402            .wHour = Hour As Word
     
    411413        Dim time As SYSTEMTIME
    412414        FileTimeToSystemTime(fileTime, time)
     415
    413416        Dim date As DateTime(time, Utc)
    414417        Return date
     
    418421        Dim fileTime As FILETIME
    419422        fileTime = ToFileTime()
    420         If Kind = 1 Then
    421             Dim utcTime As FILETIME
    422             LocalFileTimeToFileTime(fileTime, ToFileTimeUtc)'Return
    423         Else
    424             Return fileTime
     423        If Kind = Utc Then
     424            ToFileTimeUtc = fileTime
     425        Else
     426            LocalFileTimeToFileTime(fileTime, ToFileTimeUtc) 'Return
    425427        End If
    426428    End Function
    427429
    428430    Function ToLocalTime() As DateTime
     431        If Kind = Local Then
     432            ToLocalTime = This
     433        Else
     434            ToLocalTime = DateTime.FromFileTime(ToFileTime())
     435            ToLocalTime.Kind = Local
     436        End If
     437    End Function
     438
     439    Function ToUniversalTime() As DateTime
    429440        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
     441            ToUniversalTime = This
     442        Else
    439443            ToUniversalTime = DateTime.FromFileTimeUtc(ToFileTimeUtc())
    440444            ToUniversalTime.Kind = Utc
    441         Else
    442             ToUniversalTime = This
    443445        End If
    444446    End Function
Note: See TracChangeset for help on using the changeset viewer.