现在的位置: 首页 > 综合 > 正文

PHP_ext_calendar L1 Study Note

2017年11月12日 ⁄ 综合 ⁄ 共 1443字 ⁄ 字号 评论关闭

1 Predefined Constants 预定义常量释义(部分)

define('CAL_GREGORIAN', 0);       // 公历 公历是现在国际通用的历法,又称格列历,通称阳历。“阳历”又名“太阳历”,系以地球绕行太阳一周为一年,为西方各国所通用,故又名“西历”。
define('CAL_JULIAN', 1);          // 儒略历 十六世纪以前西方采用的一种历法,在公元46年由罗马统治者儒略·凯撒颁行。历年平均长度为365.25日。
define('CAL_JEWISH', 2);          // 伯来历 又称为犹太历,是以色列国目前使用的古老历法,是一种阴阳合历。
define('CAL_FRENCH', 3);          // 法国共和历 法国大革命中一度实行的历法。1793年10月 5日国民公会决定废止基督教的格里历法(即公历),采用革命历法,即共和历。
define('CAL_NUM_CALS', 4);	  // 以上四种历法的ID,在cal_from_jd (可从calendar.c 中查看)中判定参数$cal 的合法性时使用
define('CAL_DOW_DAYNO', 0);       // day of week day number:0 1 2 3 4 5 6 (可从dow.c 中查看)
define('CAL_DOW_SHORT', 1);	  // day of week short name:"Sun","Mon","Tue","Wed","Thu","Fri","Sat"
define('CAL_DOW_LONG', 2);	  // day of week long name :"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"

2 Functions 解释

PHP_FUNCTION(jdtogregorian);	  // jd: julian day
PHP_FUNCTION(gregoriantojd);
PHP_FUNCTION(jdtojulian);
PHP_FUNCTION(juliantojd);
PHP_FUNCTION(jdtojewish);
PHP_FUNCTION(jewishtojd);
PHP_FUNCTION(jdtofrench);
PHP_FUNCTION(frenchtojd);
PHP_FUNCTION(jddayofweek);	  // 如上 1 所示,参数$mode 选择那种显示方式(默认是 CAL_DOW_DAYNO)
PHP_FUNCTION(jdmonthname);
PHP_FUNCTION(easter_days);
PHP_FUNCTION(easter_date);
PHP_FUNCTION(unixtojd);		  // unix: timestamp
PHP_FUNCTION(jdtounix);
PHP_FUNCTION(cal_from_jd);
PHP_FUNCTION(cal_to_jd);
PHP_FUNCTION(cal_days_in_month); // 某个月中的天数
PHP_FUNCTION(cal_info);

关于各个函数的参数,需要注意的是关于独立的YMDHIS大多数为非字符型。从calendar.c 中可以查看到,分别为long 和 int 类型。如:

PHP_FUNCTION(jdtojewish)
{
	long julday, fl = 0;
	zend_bool heb   = 0;
	int year, month, day;
	char date[16], hebdate[32];
	char *dayp, *yearp;

抱歉!评论已关闭.