Overview: ISO 8601 is the standard format for representing dates and times in APIs, including Vetspire. This standardized format ensures consistency and clarity when dealing with date and time data across different systems.
Key Components of ISO 8601:
Date Only:
Format:
YYYY-MM-DD
Example:
2025-01-10
Date and Time:
Format:
YYYY-MM-DDTHH:mm:ss.sssZ
Example:
2025-01-10T15:23:42.123Z
The "T" separates the date and time components.
"Z" denotes UTC (Coordinated Universal Time).
Time Only:
Format:
HH:mm:ss.sssZ
Example:
15:23:42.123Z
Valid and Invalid Examples:
Valid:
2025-01-13T14:30:00Z
Invalid:
2025-01-13 14:30:00Z
(missing the "T").
Usage in Vetspire
Vetspire employs ISO 8601 format for various time-based fields within its API. Here are common examples of how these formats are applied:
1. Start and End Times
Purpose: Define the beginning and end of events such as appointments or logs.
Examples:
"start": "2025-01-13T07:00:00.000Z"
"end": "2025-01-14T06:59:59.999Z"
2. Date Only
Purpose: Specify dates without time, often for events or markers that span the entire day.
Example:
"date": "2025-01-13"
3. Timestamps
Purpose: Record exact moments of activity, such as when a record was inserted or modified.
Examples:
"insertedAt": "2025-01-13T15:19:02Z"
"datetime": "2025-01-13T15:25:32Z"
Best Practices for ISO 8601 in Vetspire
Always Use "T":
Ensure the "T" is included between the date and time for validity.
Use "Z" for UTC Time:
Convert local time to UTC and append "Z" for consistency across systems.
Precision:
Use milliseconds (
.sss
) when required for time-sensitive operations.
Validation:
Validate ISO 8601 formats programmatically to avoid errors.
Documentation Reference:
For detailed API integration, refer to the Vetspire API documentation at Vetspire Developer Portal.
Sample Code for Implementing ISO 8601 in APIs
Here’s an example of a JSON payload using ISO 8601:
json
Copy code
{ "event": { "name": "Appointment", "start": "2025-01-13T07:00:00.000Z", "end": "2025-01-14T06:59:59.999Z", "createdAt": "2025-01-12T16:45:30.123Z" } }
Common Errors and Troubleshooting
Missing "T":
Error:
"2025-01-13 14:30:00Z"
Fix: Ensure the format is
"2025-01-13T14:30:00Z"
.
Time Zone Misalignment:
Error: Local times differ from UTC.
Fix: Convert local time to UTC before using.
Precision Issues:
Error: Dropping milliseconds affects timestamp accuracy.
Fix: Always include
.sss
if required by the API.
Further Reading and Support
Visit Vetspire Documentation for comprehensive guidance.
Use Vetspire's API GraphiQL interface for testing: GraphiQL.
This document provides a concise but thorough understanding of ISO 8601 and its application in Vetspire systems. Let me know if you need assistance with specific examples or integration scenarios!
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article