climsoft / climsoft-web

Climsoft web application
MIT License
1 stars 6 forks source link

Adoption of ISO 8601 Date Time Format in API Communication #21

Open Patowhiz opened 6 months ago

Patowhiz commented 6 months ago

Overview I propose we standardise the Date Time format used in API communication to the ISO 8601 format. All Date Time parameters must be converted to UTC and follow the YYYY-MM-DDTHH:mm:ss.sssZ format (e.g., 2024-03-10T21:00:00.000Z) for both sending to and receiving from the API.

Proposed Structure

  1. Date Time Format: All API routes(those that relate to date time ) expect Date Time parameters in UTC, specifically in the ISO 8601 format.
  2. Underlying Implementation: The API utilizes TypeORM for CRUD operations, which converts string DateTime parameters into JavaScript Date objects for timestamptz column operations.
  3. Frontend and Backend Communication: Both frontend and backend, developed in JavaScript, will adhere to this standardized Date Time format for ease of data manipulation and communication.
  4. Database Interaction: When interacting directly with the PostgreSQL database, especially for raw queries, the extended ISO 8601 SQL standard format (YYYY-MM-DD HH:mm:ss.sss ±[hh]) should be used, acknowledging PostgreSQL's format requirements for timestamptz columns.

Rationale The decision to use the mentioned ISO 8601 format over the SQL date time standard is influenced by:

  1. Global Standardization: ISO 8601 is a globally recognized standard, facilitating easier integration and consistent formatting across different systems and technologies.
  2. Ecosystem Cohesion: The exclusive use of JavaScript across our stack simplifies DateTime handling and conversion, reducing the risk of format-related errors.
  3. Compatibility with TypeORM: TypeORM's reliance on JavaScript Date objects makes ISO 8601 the more compatible choice for our operations.
  4. UTC settings: ISO 8601 format will ensure consistency with our reliance on UTC settings for date time operations as outlined in issue #20.

Expected Benefits

Request for Comments I invite all team members to review this proposal and provide feedback or concerns regarding this adoption for our API communications. Your insights are invaluable in ensuring that we choose the most effective and efficient approach to Date Time handling in our system.