Skip to content

Instantly share code, notes, and snippets.

@honda0510
Created October 4, 2012 12:55
Show Gist options
  • Save honda0510/3833375 to your computer and use it in GitHub Desktop.
Save honda0510/3833375 to your computer and use it in GitHub Desktop.
UTCをJSTに変換
Option Explicit
Sub test()
Dim WmiDateTime As WmiDateTime
Set WmiDateTime = New WmiDateTime
WmiDateTime.Value = "20121004010446.000000-000"
Debug.Print WmiDateTime.LocalDateTime
' 2012/10/04 10:04:46
WmiDateTime.Value = "20121004100446.000000+540"
Debug.Print WmiDateTime.LocalDateTime
' 2012/10/04 10:04:46
End Sub
Option Explicit
Private m_datetime As Object
Private Sub Class_Initialize()
Set m_datetime = CreateObject("WbemScripting.SWbemDateTime")
End Sub
Public Property Let Value(WmiDateTime As String)
m_datetime.Value = WmiDateTime
End Property
Public Property Get Value() As String
Value = m_datetime.Value
End Property
Public Sub SetDateTime(DateTime As Date, Optional IsLocal As Boolean = True)
m_datetime.SetVarDate DateTime, IsLocal
End Sub
Public Property Get LocalDateTime() As Date
LocalDateTime = m_datetime.GetVarDate(True)
End Property
Public Property Get UTC() As Date
UTC = m_datetime.GetVarDate(False)
End Property
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment