Skip to content

time: parse_http_header_string#26636

Merged
JalonSolov merged 8 commits into
vlang:masterfrom
Bruno-Vdr:master
Feb 25, 2026
Merged

time: parse_http_header_string#26636
JalonSolov merged 8 commits into
vlang:masterfrom
Bruno-Vdr:master

Conversation

@Bruno-Vdr

Copy link
Copy Markdown
Contributor

An attempt to implement #26166 feature.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b96e76620

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread vlib/time/parse.c.v
if r := parse_format(f, 'DD MMM YYYY HH:mm:ss') {
return r
}
if r := parse_format(f, 'DD MMM YY HH:mm:ss') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Interpret RFC850 2-digit years using HTTP-date rules

The RFC850 branch currently parses DD MMM YY HH:mm:ss directly, which maps YY into the current century, so inputs like Sunday, 06-Nov-94 08:49:37 GMT resolve to 2094 when run today instead of 1994. That breaks legacy HTTP-date parsing and can produce incorrect expiration/cache times for any obsolete RFC850 header with a year suffix greater than the current year suffix.

Useful? React with 👍 / 👎.

@JalonSolov JalonSolov Feb 23, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@Bruno-Vdr can you take care of this change? Shouldn't take more than checking year > current year, add century - 1, else add century.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will do it soon.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I need help here:
Tuesday, 06-Nov-94 11:07:09 GMT should map to 1994 (because otherwise it points to future date).
Friday, 06-Nov-20 08:49:37 GMT should map on 2020 instead of 1920 because at this time http header weren’t widely used ? If this last statement is true, I don't need to add a century, because it already maps to this century. Am I Right ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

94 > 26, so should map to 1994. 20 <= 26, so should map to 2020. If a 4-digit year is given, it should be used as-is.

As long as the automatic handling treats <= current year as being in current century, you are correct that you don't need to add the century... through when you parse it, it would be more consistent to add it anyway.

Comment thread vlib/time/parse_test.v Outdated
Comment thread vlib/time/parse_test.v Outdated
@JalonSolov JalonSolov merged commit 8902db4 into vlang:master Feb 25, 2026
78 checks passed
cestef pushed a commit to cestef/v that referenced this pull request Mar 9, 2026
* Implemented rfc2616 parse_http_header_string.

* Corrected typos.

* Update vlib/time/parse_test.v

* Fixed YY date issue. If parsed year exceed current year, it's considered to be from the previous century.

---------

Co-authored-by: Swastik Baranwal <swstkbaranwal@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants