1
1
Attribute VB_Name = "UtcConverter"
2
2
''
3
- ' VBA-UTC v1.0.0-rc.4
3
+ ' VBA-UTC v1.0.0
4
4
' (c) Tim Hall - https://github.com/VBA-tools/VBA-UtcConverter
5
5
'
6
6
' UTC/ISO 8601 Converter for VBA
@@ -14,7 +14,7 @@ Attribute VB_Name = "UtcConverter"
14
14
' @module UtcConverter
15
15
16
16
' @license MIT (http://www.opensource.org/licenses/mit-license.php)
17
- ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
17
+ '' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
18
18
19
19
#If Mac Then
20
20
@@ -86,6 +86,7 @@ End Type
86
86
' @method ParseUtc
87
87
' @param {Date} UtcDate
88
88
' @return {Date} Local date
89
+ ' @throws 10011 - UTC parsing error
89
90
''
90
91
Public Function ParseUtc (utc_UtcDate As Date ) As Date
91
92
On Error GoTo utc_ErrorHandling
@@ -114,6 +115,7 @@ End Function
114
115
' @method ConvertToUrc
115
116
' @param {Date} utc_LocalDate
116
117
' @return {Date} UTC date
118
+ ' @throws 10012 - UTC conversion error
117
119
''
118
120
Public Function ConvertToUtc (utc_LocalDate As Date ) As Date
119
121
On Error GoTo utc_ErrorHandling
@@ -142,6 +144,7 @@ End Function
142
144
' @method ParseIso
143
145
' @param {Date} utc_IsoString
144
146
' @return {Date} Local date
147
+ ' @throws 10013 - ISO 8601 parsing error
145
148
''
146
149
Public Function ParseIso (utc_IsoString As String ) As Date
147
150
On Error GoTo utc_ErrorHandling
@@ -217,6 +220,7 @@ End Function
217
220
' @method ConvertToIso
218
221
' @param {Date} utc_LocalDate
219
222
' @return {Date} ISO 8601 string
223
+ ' @throws 10014 - ISO 8601 conversion error
220
224
''
221
225
Public Function ConvertToIso (utc_LocalDate As Date ) As String
222
226
On Error GoTo utc_ErrorHandling
@@ -234,6 +238,7 @@ End Function
234
238
' ============================================= '
235
239
236
240
#If Mac Then
241
+
237
242
Private Function utc_ConvertDate (utc_Value As Date , Optional utc_ConvertToUtc As Boolean = False ) As Date
238
243
Dim utc_ShellCommand As String
239
244
Dim utc_Result As utc_ShellResult
@@ -264,6 +269,7 @@ Private Function utc_ConvertDate(utc_Value As Date, Optional utc_ConvertToUtc As
264
269
TimeSerial(utc_TimeParts(0 ), utc_TimeParts(1 ), utc_TimeParts(2 ))
265
270
End If
266
271
End Function
272
+
267
273
Private Function utc_ExecuteInShell (utc_ShellCommand As String ) As utc_ShellResult
268
274
Dim utc_File As Long
269
275
Dim utc_Chunk As String
@@ -286,7 +292,9 @@ Private Function utc_ExecuteInShell(utc_ShellCommand As String) As utc_ShellResu
286
292
utc_ErrorHandling:
287
293
utc_ExecuteInShell.utc_ExitCode = utc_pclose(utc_File)
288
294
End Function
295
+
289
296
#Else
297
+
290
298
Private Function utc_DateToSystemTime (utc_Value As Date ) As utc_SYSTEMTIME
291
299
utc_DateToSystemTime.utc_wYear = VBA.Year(utc_Value)
292
300
utc_DateToSystemTime.utc_wMonth = VBA.Month(utc_Value)
@@ -301,4 +309,5 @@ Private Function utc_SystemTimeToDate(utc_Value As utc_SYSTEMTIME) As Date
301
309
utc_SystemTimeToDate = DateSerial(utc_Value.utc_wYear, utc_Value.utc_wMonth, utc_Value.utc_wDay) + _
302
310
TimeSerial(utc_Value.utc_wHour, utc_Value.utc_wMinute, utc_Value.utc_wSecond)
303
311
End Function
312
+
304
313
#End If
0 commit comments