$dotw) { $ys+=(((7-sd_date('N',$ys))+$dotw)*60*60*24); } else { $ys+=(($dotw-sd_date('N',$ys))*60*60*24); } $ys+=(($wn-1)*60*60*24*7); $did = sd_getMonthStart(sd_date('m',$ys)-1); $did += (sd_date('j',$ys)-1); sd_addDateIn($id,$did); } function sd_getMonthStart($month) { if ($month==0) { return 0; } else { $c = sd_daysInMonth($month-1)+sd_getMonthStart($month-1); if (date('F jS Y',sd_clearDate()+($c*60*60*24)) == 'March 31st 2008' || $month == 2) { // echo($month . ':' . sd_daysInMonth($month-1) . ':' . sd_getMonthStart($month-1) . "\n"); } return ($c); } } function sd_daysInMonth($month) { switch ($month) { case 0: return 31; case 1: return (28+sd_isLeapYear()); case 2: return 31; case 3: return 30; case 4: return 31; case 5: return 30; case 6: return 31; case 7: return 31; case 8: return 30; case 9: return 31; case 10: return 30; case 11: return 31; default: throw new Exception('Invalid month ID'); } } function sd_isLeapYear() { return sd_date('L'); } function sd_isSpecialDay($id) { global $specialdates; $did = sd_getMonthStart(sd_date('n')-1); $did += (sd_date('j')-1); if ($specialdates[$did] == $id) { return 1; } else { return 0; } } function sd_ifNoSpecialDay() { global $specialdates; $did = sd_getMonthStart(sd_date('n')-1); $did += (sd_date('j')-1); if ($specialdates[$did] == '') { return 1; } else { return 0; } } function sd_kirbyWeek() { $did = sd_getMonthStart(11); $ys = sd_clearDate(); $ys+=(60*60*24*24); $ys+=(60*60*24*$did); $tWD=sd_date('N',$ys); if ($tWD==7) {$tWD=0;} $ys-=($tWD*60*60*24); $ys-=(60*60*24*7); sd_solar_annual('Kirby Week',12,sd_date('j',$ys)); sd_solar_annual('Kirby Week',12,sd_date('j',$ys)+1); sd_solar_annual('Kirby Week',12,sd_date('j',$ys)+2); sd_solar_annual('Kirby Week',12,sd_date('j',$ys)+3); sd_solar_annual('Kirby Week',12,sd_date('j',$ys)+4); sd_solar_annual('Kirby Week',12,sd_date('j',$ys)+5); sd_solar_annual('Kirby Week',12,sd_date('j',$ys)+6); } function sd_easter() { $nYear = sd_date('Y'); $nCent = $nYear/100; $nRemain19 = $nYear%19; $n1 = ($nCent-15)/2+202-11*$nRemain19; if ($nCent>20) { if ($nCent>26) {$n1--;} if ($nCent>38) {$n1--;} if ($nCent==21 || $nCent==24 || $nCent==25 || $nCent==33 || $nCent==36 || $nCent==37) {$n1--;} } $n1%=30; if ($n1==29 || ($n1 && $nRemain19>10)) {$n1--;} $ys = sd_clearDate(); if ($n1>10) { $ys+=(60*60*24*sd_getMonthStart(3)); $ys+=(60*60*24*($n1-10-1)); } else { $ys+=(60*60*24*sd_getMonthStart(2)); $ys+=(60*60*24*($n1+21-1)); } $nWD = sd_date('N',$ys); if ($nWD==7) {$nWD=0;} $ys+=(60*60*24*(7-$nWD)); sd_solar_annual('Easter',sd_date('m',$ys),sd_date('j',$ys)); $ys-=(60*60*24*46);
// (‑●‑●)> dual licensed under the WTFPL v2 and MIT licenses
// without any warranty.
// by Gregory Pakosz (@gpakosz)
// https://github.com/gpakosz/whereami
#ifndef WHEREAMI_H
#define WHEREAMI_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef WAI_FUNCSPEC
#define WAI_FUNCSPEC
#endif
#ifndef WAI_PREFIX
#define WAI_PREFIX(function) wai_##function
#endif
/**
* Returns the path to the current executable.
*
* Usage:
* - first call `int length = wai_getExecutablePath(NULL, 0, NULL);` to
* retrieve the length of the path
* - allocate the destination buffer with `path = (char*)malloc(length + 1);`
* - call `wai_getExecutablePath(path, length, NULL)` again to retrieve the
* path
* - add a terminal NUL character with `path[length] = '\0';`
*
* @param out destination buffer, optional
* @param capacity destination buffer capacity
* @param dirname_length optional recipient for the length of the dirname part
* of the path.
*
* @return the length of the executable path on success (without a terminal NUL
* character), otherwise `-1`
*/
WAI_FUNCSPEC
int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length);
/**
* Returns the path to the current module
*
* Usage:
* - first call `int length = wai_getModulePath(NULL, 0, NULL);` to retrieve
* the length of the path
* - allocate the destination buffer with `path = (char*)malloc(length + 1);`
* - call `wai_getModulePath(path, length, NULL)` again to retrieve the path
* - add a terminal NUL character with `path[length] = '\0';`
*
* @param out destination buffer, optional
* @param capacity destination buffer capacity
* @param dirname_length optional recipient for the length of the dirname part
* of the path.
*
* @return the length of the module path on success (without a terminal NUL
* character), otherwise `-1`
*/
WAI_FUNCSPEC
int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length);
#ifdef __cplusplus
}
#endif
#endif // #ifndef WHEREAMI_H