Skip to content

fix(date): improve caching accuracy#3887

Merged
seanmonstar merged 1 commit into
hyperium:masterfrom
Patryk27:fix/date-accuracy
May 19, 2025
Merged

fix(date): improve caching accuracy#3887
seanmonstar merged 1 commit into
hyperium:masterfrom
Patryk27:fix/date-accuracy

Conversation

@Patryk27

@Patryk27 Patryk27 commented May 8, 2025

Copy link
Copy Markdown
Contributor

CachedDate gets updated every second, but the current logic doesn't take into account milliseconds and nanoseconds - if the application starts at 12:00:00.600, hyper will report date: ...T120000 up until 12:00:01.600, which is overzealous.

We can sidestep this by subtracting the nanoseconds part (which includes milliseconds) from the time passed to CachedDate::update(), essentially rounding self.next_update to the beginning of the next closest second.

`CachedDate` gets updated every second, but the current logic doesn't
take into account milliseconds - if the application starts at
`12:00:00.600`, hyper will report `date: ...T120000` up until
`12:00:01.599`, which is overzealous.

We can sidestep this by subtracing the nanoseconds part (which includes
milliseconds) from the time passed to `CachedDate::update()`.

@seanmonstar seanmonstar left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, thanks!

@seanmonstar seanmonstar merged commit 436cadd into hyperium:master May 19, 2025
@Patryk27 Patryk27 deleted the fix/date-accuracy branch May 20, 2025 07:53
LBeernaertProton pushed a commit to ProtonMail/clients that referenced this pull request May 29, 2026
hyperium/hyper#3887 got merged, so we can change
the pin from my private repo to the official one.

This change hasn't been released yet, though.
LBeernaertProton pushed a commit to ProtonMail/clients that referenced this pull request May 29, 2026
hyperium/hyper#3887 got merged, so we can change
the pin from my private repo to the official one.

This change hasn't been released yet, though.
LBeernaertProton pushed a commit to ProtonMail/clients that referenced this pull request Jun 24, 2026
hyperium/hyper#3887 got merged, so we can change
the pin from my private repo to the official one.

This change hasn't been released yet, though.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants