函数文档

calendar_week_mod()

💡 云策文档标注

概述

calendar_week_mod() 是一个 WordPress 函数,用于计算给定天数相对于一周起始的天数偏移。它基于模运算实现,返回一个浮点数表示结果。

关键要点

  • 函数接受一个整数参数 $num,表示天数
  • 返回值为浮点数,表示从一周起始开始的天数
  • 内部使用公式 ( $num - 7 * floor( $num / 7 ) ) 进行计算
  • 该函数自 WordPress 1.5.0 版本引入
  • 主要用于 get_calendar() 函数中,辅助生成日历显示

代码示例

echo calendar_week_mod( 10 );
// 输出: 3

📄 原文内容

Gets number of days since the start of the week.

Parameters

$numintrequired
Number of day.

Return

float Days since the start of the week.

Source

function calendar_week_mod( $num ) {
	$base = 7;
	return ( $num - $base * floor( $num / $base ) );
}

Changelog

Version Description
1.5.0 Introduced.

User Contributed Notes