Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTime parsing problem #186

Open
nszabogb opened this issue Jan 8, 2025 · 1 comment
Open

DateTime parsing problem #186

nszabogb opened this issue Jan 8, 2025 · 1 comment

Comments

@nszabogb
Copy link

nszabogb commented Jan 8, 2025

Problem

Email date/time parsing often fails

local_date_time message::parse_date(const string& date_str) const function returns not_a_date_time whenever the timezone offset is not included in the email time stamp. This is a usual occurrence.

My suggested solution:

local_date_time message::parse_date(const string& date_str) const
{
    try
    {
        string tmp_date_str(date_str);
        if (date_str.find('+') == string::npos)
            tmp_date_str+=" +0000";

        // date format to be parsed is like "Thu, 17 Jul 2014 10:31:49 +0200 (CET)"
        regex r(R"(([A-Za-z]{3}[\ \t]*,)[\ \t]+(\d{1,2}[\ \t]+[A-Za-z]{3}[\ \t]+\d{4})[\ \t]+(\d{2}:\d{2}:\d{2}[\ \t]+(\+|\-)\d{4}).*)");
        smatch m;
        if (regex_match(tmp_date_str, m, r))
        {
...
@karastojko
Copy link
Owner

According to the RFC 5322 section 3.3, the timezone is mandatory. In case it is neglected, it should be in the non-strict mode. Can you please tell me from which email server or client you are experiencing this case? I do not recall I had it.

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

No branches or pull requests

2 participants