Document: Understanding ISO 8601 Format in Vetspire

Modified on Fri, Feb 7 at 2:54 PM

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:

  1. Date Only:

    • Format: YYYY-MM-DD

    • Example: 2025-01-10

  2. 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).

  3. Time Only:

    • Format: HH:mm:ss.sssZ

    • Example: 15:23:42.123Z

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

  1. Always Use "T":

    • Ensure the "T" is included between the date and time for validity.

  2. Use "Z" for UTC Time:

    • Convert local time to UTC and append "Z" for consistency across systems.

  3. Precision:

    • Use milliseconds (.sss) when required for time-sensitive operations.

  4. Validation:

    • Validate ISO 8601 formats programmatically to avoid errors.

  5. Documentation Reference:


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

  1. Missing "T":

    • Error: "2025-01-13 14:30:00Z"

    • Fix: Ensure the format is "2025-01-13T14:30:00Z".

  2. Time Zone Misalignment:

    • Error: Local times differ from UTC.

    • Fix: Convert local time to UTC before using.

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

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article

https://support.vetspire.com/a/admin/portals/70000004548/themes