gchq / gchq/event-logging

Pre-epoch timestamps produce invalid millisecond fields

Open Beginner friendly
#20 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
17
Forks
11
PR merge metrics
No merged PRs in 30d

Description

`DateUtil.createNormalDateTimeString` computes the millisecond fraction with truncating integer division. For timestamps before the Unix epoch this can produce a negative fraction.

For example, `DateUtil.createNormalDateTimeString(-1L)` currently returns `1969-12-31T23:59:59.0-1Z` instead of `1969-12-31T23:59:59.999Z`. The same path is used by `InstantAdapter.printDate`, so pre-1970 instants do not round-trip correctly.

The fraction should use floor-modulo semantics so it is always in the range 0-999. A regression test should cover both formatting and round-trip parsing.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with DateUtil.createNormalDateTimeString and trace its use from InstantAdapter.printDate. Reproduce the -1L example, then inspect the existing date-formatting and parsing tests to add coverage for pre-epoch formatting and round-trip parsing. Done means the millisecond field is always 0-999 and the regression tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.