Is leap year calculation omitted?
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with plugins/sudoers/getdate.c and trace how Convert computes the Julian day from EPOCH through the requested year. Compare that loop with the leap year check already used for DaysInMonth, then inspect or run the date parsing tests mentioned by the project. Done means leap days are handled consistently across century years and the relevant tests pass.
由索引模型根据 Issue 内容生成。
描述
Hi,all
in plugins/sudoers/getdate.c
static time_t
Convert(time_t Month, time_t Day, time_t Year, time_t Hours, time_t Minutes,
time_t Seconds, MERIDIAN Meridian, DSTMODE DSTmode)
{
static int DaysInMonth[12] = {
31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
};
struct tm tm;
time_t tod;
time_t Julian;
int i;
if (Year < 0)
Year = -Year;
if (Year < 69)
Year += 2000;
else if (Year < 100) {
Year += 1900;
if (Year < EPOCH)
Year += 100;
}
DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0)
? 29 : 28;
/* 32-bit time_t cannot represent years past 2038 */
if (Year < EPOCH || (sizeof(time_t) == sizeof(int) && Year > 2038)
|| Month < 1 || Month > 12
/* Lint fluff: "conversion from long may lose accuracy" */
|| Day < 1 || Day > DaysInMonth[--Month])
return -1;
for (Julian = Day - 1, i = 0; i < Month; i++)
Julian += DaysInMonth[i];
for (i = EPOCH; i < Year; i++)
Julian += 365 + (i % 4 == 0);
Julian *= SECSPERDAY;
Julian += yyTimezone * 60L;
if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0)
return -1;
Julian += tod;
if (DSTmode == DSTon
|| (DSTmode == DSTmaybe && localtime_r(&Julian, &tm) && tm.tm_isdst))
Julian -= 60 * 60;
return Julian;
for (i = EPOCH; i < Year; i++)
Julian += 365 + (i % 4 == 0); //Only %4 was calculated. %100 and %400 were not calculated
Should it be Julian += 365 + (i % 4 == 0 && (i % 100 != 0 || i % 400 == 0)); ?
- 主要语言
- C
- 星标
- 1.7k
- 派生
- 306
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 24
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sudo-project/sudo 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 42/100
sudo-project/sudo#583 ·
维护者通常 1 天内回复
-
Signal forwarded to the command is lost when it arrives between fork() and execve() of the command未关闭
难度 4/5 3-5 天 新手友好度 35/100
sudo-project/sudo#566 ·
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 52/100
sudo-project/sudo#553 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 48/100
sudo-project/sudo#552 ·
维护者通常 1 天内回复
-
Documentation text overflows container instead of wrapping可能重新可做 @BittuBarnwal7479 于 130 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 58/100
sudo-project/sudo#547 · 1 条评论 ·
维护者通常 1 天内回复
查看 sudo-project/sudo 的全部 Issue
相似的 Issue
-
vim.filetype.match() prefixes a URL buffer name with the cwd before passing it to filetype functions未关闭
难度 2/5 1-3 小时 新手友好度 73/100
维护者通常 1 天内回复
-
stream_curl: retry_count never resets after a successful reconnect, so long sequential streams die after 5 drops可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
mpv-player/mpv#18728 ·
维护者通常 1 天内回复
-
followup Prio 📌
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
cyrusimap/cyrus-imapd#6640 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 60/100
维护者通常 1 天内回复