-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
11 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Attribute VB_Name = "UtcConverter" | ||
'' | ||
' VBA-UTC v1.0.0-rc.4 | ||
' VBA-UTC v1.0.0 | ||
' (c) Tim Hall - https://github.com/VBA-tools/VBA-UtcConverter | ||
' | ||
' UTC/ISO 8601 Converter for VBA | ||
|
@@ -14,7 +14,7 @@ Attribute VB_Name = "UtcConverter" | |
' @module UtcConverter | ||
' @author [email protected] | ||
' @license MIT (http://www.opensource.org/licenses/mit-license.php) | ||
' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' | ||
'' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ' | ||
|
||
#If Mac Then | ||
|
||
|
@@ -86,6 +86,7 @@ End Type | |
' @method ParseUtc | ||
' @param {Date} UtcDate | ||
' @return {Date} Local date | ||
' @throws 10011 - UTC parsing error | ||
'' | ||
Public Function ParseUtc(utc_UtcDate As Date) As Date | ||
On Error GoTo utc_ErrorHandling | ||
|
@@ -114,6 +115,7 @@ End Function | |
' @method ConvertToUrc | ||
' @param {Date} utc_LocalDate | ||
' @return {Date} UTC date | ||
' @throws 10012 - UTC conversion error | ||
'' | ||
Public Function ConvertToUtc(utc_LocalDate As Date) As Date | ||
On Error GoTo utc_ErrorHandling | ||
|
@@ -142,6 +144,7 @@ End Function | |
' @method ParseIso | ||
' @param {Date} utc_IsoString | ||
' @return {Date} Local date | ||
' @throws 10013 - ISO 8601 parsing error | ||
'' | ||
Public Function ParseIso(utc_IsoString As String) As Date | ||
On Error GoTo utc_ErrorHandling | ||
|
@@ -217,6 +220,7 @@ End Function | |
' @method ConvertToIso | ||
' @param {Date} utc_LocalDate | ||
' @return {Date} ISO 8601 string | ||
' @throws 10014 - ISO 8601 conversion error | ||
'' | ||
Public Function ConvertToIso(utc_LocalDate As Date) As String | ||
On Error GoTo utc_ErrorHandling | ||
|
@@ -234,6 +238,7 @@ End Function | |
' ============================================= ' | ||
|
||
#If Mac Then | ||
|
||
Private Function utc_ConvertDate(utc_Value As Date, Optional utc_ConvertToUtc As Boolean = False) As Date | ||
Dim utc_ShellCommand As String | ||
Dim utc_Result As utc_ShellResult | ||
|
@@ -264,6 +269,7 @@ Private Function utc_ConvertDate(utc_Value As Date, Optional utc_ConvertToUtc As | |
TimeSerial(utc_TimeParts(0), utc_TimeParts(1), utc_TimeParts(2)) | ||
End If | ||
End Function | ||
|
||
Private Function utc_ExecuteInShell(utc_ShellCommand As String) As utc_ShellResult | ||
Dim utc_File As Long | ||
Dim utc_Chunk As String | ||
|
@@ -286,7 +292,9 @@ Private Function utc_ExecuteInShell(utc_ShellCommand As String) As utc_ShellResu | |
utc_ErrorHandling: | ||
utc_ExecuteInShell.utc_ExitCode = utc_pclose(utc_File) | ||
End Function | ||
|
||
#Else | ||
|
||
Private Function utc_DateToSystemTime(utc_Value As Date) As utc_SYSTEMTIME | ||
utc_DateToSystemTime.utc_wYear = VBA.Year(utc_Value) | ||
utc_DateToSystemTime.utc_wMonth = VBA.Month(utc_Value) | ||
|
@@ -301,4 +309,5 @@ Private Function utc_SystemTimeToDate(utc_Value As utc_SYSTEMTIME) As Date | |
utc_SystemTimeToDate = DateSerial(utc_Value.utc_wYear, utc_Value.utc_wMonth, utc_Value.utc_wDay) + _ | ||
TimeSerial(utc_Value.utc_wHour, utc_Value.utc_wMinute, utc_Value.utc_wSecond) | ||
End Function | ||
|
||
#End If |
Binary file not shown.