Parse a Structured Date/Time String in Python

Cloudmersive
2 min readDec 2, 2020

Logging information from data sheets can be time consuming and tedious. Furthermore, mistakes can occur when you must look line by line for the data that you need. When working with dates and time, this can mean missing an important deadline or setting a meeting for the improper time. To combat this, the following API will allow you to parse structured date/time information into separate objects, instantly. The only necessary input for this function is the raw date/time input and the relevant country code.

You can use this API by running this command to install the SDK:

pip install cloudmersive-validate-api-client

Then, you can call the function:

from __future__ import print_function
import time
import cloudmersive_validate_api_client
from cloudmersive_validate_api_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: Apikey
configuration = cloudmersive_validate_api_client.Configuration()
configuration.api_key['Apikey'] = 'YOUR_API_KEY'
# create an instance of the API class
api_instance = cloudmersive_validate_api_client.DateTimeApi(cloudmersive_validate_api_client.ApiClient(configuration))
input = cloudmersive_validate_api_client.DateTimeStandardizedParseRequest() # DateTimeStandardizedParseRequest | Input request
try:
# Parses a standardized date and time string into a date and time
api_response = api_instance.date_time_parse_standard_date_time(input)
pprint(api_response)
except ApiException as e:
print("Exception when calling DateTimeApi->date_time_parse_standard_date_time: %s\n" % e)

This will return each value as a separate object, that can then be categorized and logged appropriately in your systems. You can retrieve the API Key from the Cloudmersive website at no cost and with no commitment. This will provide you with 800 monthly calls across our library of APIs.

--

--

Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.