Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Parse a Microsoft JSON Date (MS AJAX Date)Demonstrates how to parse a Microsoft JSON Date, also known as an MSAJAX date. Note: This example requires Chilkat v9.5.0.76 or greater.
Use ChilkatAx-win32.pkg Procedure Test Handle hoJson Boolean iSuccess Variant vDt Handle hoDt Boolean iBLocal Variant vDtObj Handle hoDtObj String sTemp1 Integer iTemp1 // Note: This example requires Chilkat v9.5.0.76 or greater. // The ability to automatically parse Microsoft JSON Dates (AJAX Dates) was added in v9.5.0.76 Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComLoad Of hoJson '{ "AchievementDate":"/Date(1540229468330-0500)/"}' To iSuccess Get Create (RefClass(cComCkDateTime)) To hoDt If (Not(IsComObjectCreated(hoDt))) Begin Send CreateComObject of hoDt End Get pvComObject of hoDt to vDt Get ComDateOf Of hoJson "AchievementDate" vDt To iSuccess If (iSuccess <> True) Begin Showln "Unable to parse a date/time." Procedure_Return End // Show the date in different formats: Move True To iBLocal Get ComGetAsRfc822 Of hoDt iBLocal To sTemp1 Showln "RFC822: " sTemp1 Get ComGetAsTimestamp Of hoDt iBLocal To sTemp1 Showln "Timestamp: " sTemp1 Get ComGetAsIso8601 Of hoDt "YYYY-MM-DD" iBLocal To sTemp1 Showln "YYYY-MM-DD: " sTemp1 // Get integer values for year, month, day, etc. Get ComGetDtObj Of hoDt iBLocal To vDtObj If (IsComObject(vDtObj)) Begin Get Create (RefClass(cComChilkatDtObj)) To hoDtObj Set pvComObject Of hoDtObj To vDtObj End Get ComYear Of hoDtObj To iTemp1 Showln "year: " iTemp1 Get ComMonth Of hoDtObj To iTemp1 Showln "month: " iTemp1 Get ComDay Of hoDtObj To iTemp1 Showln "day: " iTemp1 Get ComHour Of hoDtObj To iTemp1 Showln "hour: " iTemp1 Get ComMinute Of hoDtObj To iTemp1 Showln "minute: " iTemp1 Get ComSecond Of hoDtObj To iTemp1 Showln "seconds: " iTemp1 Send Destroy of hoDtObj // Sample output: // RFC822: Mon, 22 Oct 2018 17:31:08 -0500 // Timestamp: 2018-10-22T17:31:08-05:00 // YYYY-MM-DD: 2018-10-22 // year: 2018 // month: 10 // day: 22 // hour: 17 // minute: 31 // seconds: 8 End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.