drogonframework/drogon

Same issue than trantor::Date https://github.com/an-tao/trantor/pull/140

クローズ

#2,534 opened on 2026/06/18

 (0 件のコメント) (0 件のリアクション) (0 人の担当者)C++ (1,014 件のフォーク)batch import
good first issue

Repository metrics

Stars
 (10,462 個のスター)
PR merge metrics
 (平均マージ 5d 16h) (30d で 3 merged PRs)

説明

Hi,

To take DST into account, mktime need tm.is_dst to be set to -1: https://en.cppreference.com/cpp/chrono/c/mktime Notes If the std::tm object was obtained from std::get_time or the POSIX [strptime](https://pubs.opengroup.org/onlinepubs/009695399/functions/strptime.html), the value of tm_isdst is indeterminate, and needs to be set explicitly before calling mktime.

The same code from trantor::Date need to be set in src/drogon_ctl/templates/model_cc.csp:

$$<<"            struct tm stm;\n";
$$<<"            memset(&stm,0,sizeof(stm));\n";
$$<<"            strptime(daysStr.c_str(),\"%Y-%m-%d\",&stm);\n";
$$<<"            time_t t = mktime(&stm);\n";

Templates need to be change into:

$$<<"            struct tm stm;\n";
$$<<"            memset(&stm,0,sizeof(stm));\n";
$$<<"            stm.is_dst = -1;\n";
$$<<"            strptime(daysStr.c_str(),\"%Y-%m-%d\",&stm);\n";
$$<<"            time_t t = mktime(&stm);\n";

thanks !

コントリビューターガイド