Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(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.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-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.