Chilkat • HOME • Android™ • AutoIt • C • C# • C++ • Chilkat2-Python • CkPython • Classic ASP • DataFlex • Delphi DLL • Go • Java • Node.js • Objective-C • PHP Extension • Perl • PowerBuilder • PowerShell • PureBasic • Ruby • SQL Server • Swift • Tcl • Unicode C • Unicode C++ • VB.NET • VBScript • Visual Basic 6.0 • Visual FoxPro • Xojo Plugin
(Unicode C++) 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.
#include <CkJsonObjectW.h> #include <CkDateTimeW.h> #include <CkDtObjW.h> void ChilkatSample(void) { // 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 CkJsonObjectW json; bool success = json.Load(L"{ \"AchievementDate\":\"/Date(1540229468330-0500)/\"}"); CkDateTimeW dt; success = json.DateOf(L"AchievementDate",dt); if (success != true) { wprintf(L"Unable to parse a date/time.\n"); return; } // Show the date in different formats: bool bLocal = true; wprintf(L"RFC822: %s\n",dt.getAsRfc822(bLocal)); wprintf(L"Timestamp: %s\n",dt.getAsTimestamp(bLocal)); wprintf(L"YYYY-MM-DD: %s\n",dt.getAsIso8601(L"YYYY-MM-DD",bLocal)); // Get integer values for year, month, day, etc. CkDtObjW *dtObj = dt.GetDtObj(bLocal); wprintf(L"year: %d\n",dtObj->get_Year()); wprintf(L"month: %d\n",dtObj->get_Month()); wprintf(L"day: %d\n",dtObj->get_Day()); wprintf(L"hour: %d\n",dtObj->get_Hour()); wprintf(L"minute: %d\n",dtObj->get_Minute()); wprintf(L"seconds: %d\n",dtObj->get_Second()); delete dtObj; // 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 } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.