|
| 1 | +# Architectural Decision Record: Timezone Handling in Project |
| 2 | + |
| 3 | +## Status |
| 4 | +Proposed |
| 5 | + |
| 6 | +## Context |
| 7 | +Our project deals with timestamp data from various sources, including SQL databases and plist files. We need a consistent approach to handle timezones across different components of our system, including LAVA, TSV, and KML outputs. The current implementation varies across modules, leading to inconsistencies and potential errors in timestamp processing. |
| 8 | + |
| 9 | +For ongoing discussion and updates related to this ADR, please refer to [Issue #850: Timezone Handling](https://github.com/abrignoni/iLEAPP/issues/850). |
| 10 | + |
| 11 | +Key issues: |
| 12 | +1. Some modules produce timestamps without timezone information. |
| 13 | +2. The `lava_insert_sqlite_data` function expects timestamps in ISO format with timezone. |
| 14 | +3. Different output formats (LAVA, TSV, KML) have different timezone requirements. |
| 15 | +4. The `timezone_offset` parameter is currently only supported in iLEAPP. |
| 16 | +5. The need to maintain compatibility with TSV and KML outputs, which benefit from timezone adjustments. |
| 17 | +6. Consideration of features in comparable commercial tools, which often include timezone adjustment capabilities. |
| 18 | + |
| 19 | +## Decision |
| 20 | +We propose the following approach for handling timezones: |
| 21 | + |
| 22 | +1. All modules should provide timestamps in one of two formats: |
| 23 | + a. Unix timestamps (assumed to be in UTC) |
| 24 | + b. ISO 8601 format with timezone specified (e.g., "2021-12-12 12:54:37+00:00") |
| 25 | + |
| 26 | +2. Maintain the `timezone_offset` parameter as an input to iLEAPP: |
| 27 | + - This parameter will continue to be used for adjusting timezones in TSV and KML outputs. |
| 28 | + - It provides consistency with features found in comparable commercial tools. |
| 29 | + - For LAVA output, all timestamps will be converted to UTC, with timezone adjustments handled by LAVA's display features. |
| 30 | + |
| 31 | +3. Update timestamp conversion functions to handle null or empty values gracefully. |
| 32 | + |
| 33 | +4. For LAVA, all timestamps should be converted to UTC, with timezone adjustments handled by LAVA's display features. |
| 34 | + |
| 35 | +## Consequences |
| 36 | +Positive: |
| 37 | +- Consistent timestamp handling across all modules |
| 38 | +- Improved compatibility with LAVA's requirements |
| 39 | +- Maintained support for timezone adjustments in TSV and KML outputs |
| 40 | +- Maintained feature parity with commercial tools regarding timezone adjustments in direct outputs (TSV, KML) |
| 41 | +- Flexibility for users to adjust timezones in non-LAVA outputs without requiring changes to the source data |
| 42 | + |
| 43 | +Negative: |
| 44 | +- Requires updates to existing modules to ensure compliance with new standards |
| 45 | +- May introduce temporary inconsistencies during the transition period |
| 46 | + |
| 47 | +Risks: |
| 48 | +- Potential for data misinterpretation if timezone information is not correctly propagated through the system |
| 49 | + |
| 50 | +## Implementation |
| 51 | +1. Update `ilapfuncs.py` to include robust timestamp conversion functions that: |
| 52 | + - Convert Unix timestamps to ISO 8601 format with UTC timezone |
| 53 | + - Add timezone information to ISO format timestamps if missing |
| 54 | + - Handle null or empty timestamp values gracefully |
| 55 | + |
| 56 | +2. Modify the `lava_insert_sqlite_data` function to accept both Unix timestamps and ISO 8601 format timestamps. |
| 57 | + |
| 58 | +3. Update all modules to use the new timestamp conversion functions when processing data. |
| 59 | + |
| 60 | +4. Ensure the `timezone_offset` parameter in iLEAPP is properly documented and its usage is clear for developers: |
| 61 | + - It should be applied to timestamp adjustments for TSV and KML outputs. |
| 62 | + - It should be ignored for LAVA output preparation, as LAVA handles timezone display internally. |
| 63 | + |
| 64 | +5. Update the documentation for users to clarify how the `timezone_offset` parameter affects different output types. |
| 65 | + |
| 66 | +## Notes |
| 67 | +- Further discussion may be needed to determine if LAVA should completely replace other report types in the future. |
| 68 | +- Consider creating a comprehensive test suite to verify correct timezone handling across all modules and output formats. |
| 69 | +- Regular code reviews should include checks for proper timestamp formatting to ensure ongoing compliance with this decision. |
| 70 | +- The decision to maintain the `timezone_offset` parameter balances the needs of different output formats and user expectations based on comparable tools in the industry. |
0 commit comments