feat: Get方式のISO8601日付文字列をyyyy/mm/dd表記に正規化、未設定日付(1899-12-30)は空欄化

NormalizeGetValueを追加し、getRecordsDataToSheetの値格納時に適用。
オブジェクト値の空欄化処理もこの関数に統合。
This commit is contained in:
Kenichiro NOGI 2026-09-11 14:30:01 +09:00
parent cb01653d77
commit 3e51710d9f

View File

@ -437,11 +437,7 @@ Function getRecordsDataToSheet(records As Collection, targetSheet As String)
Dim curRec As Dictionary Dim curRec As Dictionary
Set curRec = flatRecords(i) Set curRec = flatRecords(i)
For j = 1 To maxCols For j = 1 To maxCols
If IsObject(curRec(headerKeys(j - 1))) Then dataArr(i, j) = NormalizeGetValue(curRec(headerKeys(j - 1)))
dataArr(i, j) = ""
Else
dataArr(i, j) = curRec(headerKeys(j - 1))
End If
Next j Next j
Next i Next i
@ -472,6 +468,29 @@ Function getRecordsDataToSheet(records As Collection, targetSheet As String)
Debug.Print "レコードのシート出力完了: " & targetSheet Debug.Print "レコードのシート出力完了: " & targetSheet
End Function End Function
'******************************************************************************
'Get方式で取得した値のうち、ISO8601形式の日付時刻文字列を正規化する
'YYYY-MM-DDThh:mm:ss形式 → "yyyy/mm/dd"、未設定を示す1899-12-30は空欄にする
'オブジェクト値JSON配列等は空欄にする
Function NormalizeGetValue(ByVal v As Variant) As Variant
If IsObject(v) Then
NormalizeGetValue = ""
Exit Function
End If
Dim s As String
s = CStr(v)
If Len(s) >= 10 And Mid(s, 5, 1) = "-" And Mid(s, 8, 1) = "-" And Mid(s, 11, 1) = "T" Then
If Left(s, 10) = "1899-12-30" Then
NormalizeGetValue = ""
Else
NormalizeGetValue = Mid(s, 1, 4) & "/" & Mid(s, 6, 2) & "/" & Mid(s, 9, 2)
End If
Else
NormalizeGetValue = v
End If
End Function
'****************************************************************************** '******************************************************************************
'REST API呼出処理 'REST API呼出処理
' method GetかPOSTか ' method GetかPOSTか