1
1
Attribute VB_Name = "JsonConverter"
2
2
''
3
- ' VBA-JSON v1.0.0-rc.6
3
+ ' VBA-JSON v1.0.0
4
4
' (c) Tim Hall - https://github.com/VBA-tools/VBA-JSON
5
5
'
6
6
' JSON Converter for VBA
7
7
'
8
- ' Errors (513-65535 available) :
8
+ ' Errors:
9
9
' 10001 - JSON parse error
10
- ' 10002 - ISO 8601 date conversion error
11
10
'
12
11
' @class JsonConverter
13
12
' @author tim.hall.engr@gmail.com
14
13
' @license MIT (http://www.opensource.org/licenses/mit-license.php)
15
- ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
14
+ '' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
16
15
'
17
16
' Based originally on vba-json (with extensive changes)
18
17
' BSD license included below
@@ -126,6 +125,7 @@ Private Declare Sub json_CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _
126
125
' @method ParseJson
127
126
' @param {String} json_String
128
127
' @return {Object} (Dictionary or Collection)
128
+ ' @throws 10001 - JSON parse error
129
129
''
130
130
Public Function ParseJson (ByVal json_String As String , Optional json_ConvertLargeNumbersToString As Boolean = True ) As Object
131
131
Dim json_Index As Long
@@ -694,7 +694,7 @@ Private Function json_UnsignedAdd(json_Start As Long, json_Increment As Long) As
694
694
End Function
695
695
696
696
''
697
- ' VBA-UTC v1.0.0-rc.4
697
+ ' VBA-UTC v1.0.0
698
698
' (c) Tim Hall - https://github.com/VBA-tools/VBA-UtcConverter
699
699
'
700
700
' UTC/ISO 8601 Converter for VBA
@@ -708,7 +708,7 @@ End Function
708
708
' @module UtcConverter
709
709
' @author tim.hall.engr@gmail.com
710
710
' @license MIT (http://www.opensource.org/licenses/mit-license.php)
711
- ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
711
+ '' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '
712
712
713
713
' (Declarations moved to top)
714
714
@@ -722,6 +722,7 @@ End Function
722
722
' @method ParseUtc
723
723
' @param {Date} UtcDate
724
724
' @return {Date} Local date
725
+ ' @throws 10011 - UTC parsing error
725
726
''
726
727
Public Function ParseUtc (utc_UtcDate As Date ) As Date
727
728
On Error GoTo utc_ErrorHandling
@@ -750,6 +751,7 @@ End Function
750
751
' @method ConvertToUrc
751
752
' @param {Date} utc_LocalDate
752
753
' @return {Date} UTC date
754
+ ' @throws 10012 - UTC conversion error
753
755
''
754
756
Public Function ConvertToUtc (utc_LocalDate As Date ) As Date
755
757
On Error GoTo utc_ErrorHandling
@@ -778,6 +780,7 @@ End Function
778
780
' @method ParseIso
779
781
' @param {Date} utc_IsoString
780
782
' @return {Date} Local date
783
+ ' @throws 10013 - ISO 8601 parsing error
781
784
''
782
785
Public Function ParseIso (utc_IsoString As String ) As Date
783
786
On Error GoTo utc_ErrorHandling
@@ -853,6 +856,7 @@ End Function
853
856
' @method ConvertToIso
854
857
' @param {Date} utc_LocalDate
855
858
' @return {Date} ISO 8601 string
859
+ ' @throws 10014 - ISO 8601 conversion error
856
860
''
857
861
Public Function ConvertToIso (utc_LocalDate As Date ) As String
858
862
On Error GoTo utc_ErrorHandling
@@ -870,6 +874,7 @@ End Function
870
874
' ============================================= '
871
875
872
876
#If Mac Then
877
+
873
878
Private Function utc_ConvertDate (utc_Value As Date , Optional utc_ConvertToUtc As Boolean = False ) As Date
874
879
Dim utc_ShellCommand As String
875
880
Dim utc_Result As utc_ShellResult
@@ -900,6 +905,7 @@ Private Function utc_ConvertDate(utc_Value As Date, Optional utc_ConvertToUtc As
900
905
TimeSerial(utc_TimeParts(0 ), utc_TimeParts(1 ), utc_TimeParts(2 ))
901
906
End If
902
907
End Function
908
+
903
909
Private Function utc_ExecuteInShell (utc_ShellCommand As String ) As utc_ShellResult
904
910
Dim utc_File As Long
905
911
Dim utc_Chunk As String
@@ -922,7 +928,9 @@ Private Function utc_ExecuteInShell(utc_ShellCommand As String) As utc_ShellResu
922
928
utc_ErrorHandling:
923
929
utc_ExecuteInShell.utc_ExitCode = utc_pclose(utc_File)
924
930
End Function
931
+
925
932
#Else
933
+
926
934
Private Function utc_DateToSystemTime (utc_Value As Date ) As utc_SYSTEMTIME
927
935
utc_DateToSystemTime.utc_wYear = VBA.Year(utc_Value)
928
936
utc_DateToSystemTime.utc_wMonth = VBA.Month(utc_Value)
@@ -937,4 +945,5 @@ Private Function utc_SystemTimeToDate(utc_Value As utc_SYSTEMTIME) As Date
937
945
utc_SystemTimeToDate = DateSerial(utc_Value.utc_wYear, utc_Value.utc_wMonth, utc_Value.utc_wDay) + _
938
946
TimeSerial(utc_Value.utc_wHour, utc_Value.utc_wMinute, utc_Value.utc_wSecond)
939
947
End Function
948
+
940
949
#End If
0 commit comments