<?php
/**
* XS2:
*
* This file is developed by Solutecs, LLC for the purpose of the company
* and is provided together with XS2 Framework as and inherent part of the
* system. This file can be used on the terms of License Agreement.
*
* +7 (495) 585-0833 / 13 Rusakovskaya street, Moscow 107140 Russia
*
* @link http://www.solutecs.com
* @copyright ©1998-2007 Solutecs, LLC
* @package XS2-MODCOM
* @subpackage proc-dating
* @version 1.XX
*/
$zodiac = array('', 'Овен', 'Телец', 'Близнецы', 'Рак',
'Лев', 'Дева', 'Весы', 'Cкорпион',
'Стрелец', 'Козерог', 'Водолей', 'Рыбы');
$_HTML->assign('zodiac', $zodiac);
$_HTML->register_function('date2zodiac', 'date2zodiac');
$_HTML->register_function('date2age', 'date2age');
// Возвращает в шаблон возраст
function date2age($params, &$smarty) {
global $_HTML;
extract($params);
if ($date) { $result = _date2age($date); }
else { $result = false; }
if ($var) { $_HTML->assign($var, $result); }
else { return $result; }
}
// Возвращает в шаблон номер знака зодиака
function date2zodiac($params, &$smarty) {
global $_HTML;
global $zodiac;
extract($params);
if ($date) { $result = _date2zodiac($date); }
else { $result = 0; }
if ($var) { $_HTML->assign($var, $result); }
else { return $result; }
}
function _date2age($date) {
$_t = explode('.', $date);
return floor((time()-(mktime(1, 1, 5, $_t[1], $_t[0], $_t[2])))/(365*24*60*60));
}
function _date2zodiac($date) {
$_t = array_map(create_function('$n', 'return (int)$n;'), explode('.', $date));
$_d = (int)date('z', mktime(1,1,1, $_t[1], $_t[0], $_t[2]));
$_z = array(array(0, 364),
array((int)date('z', mktime(1,1,1, 3, 21, $_t[2])), (int)date('z', mktime(1,1,1, 4, 20, $_t[2]))), // Овен
array((int)date('z', mktime(1,1,1, 4, 21, $_t[2])), (int)date('z', mktime(1,1,1, 5, 20, $_t[2]))), // Телец
array((int)date('z', mktime(1,1,1, 5, 21, $_t[2])), (int)date('z', mktime(1,1,1, 6, 21, $_t[2]))), // Близнецы
array((int)date('z', mktime(1,1,1, 6, 22, $_t[2])), (int)date('z', mktime(1,1,1, 7, 22, $_t[2]))), // Рак
array((int)date('z', mktime(1,1,1, 7, 23, $_t[2])), (int)date('z', mktime(1,1,1, 8, 23, $_t[2]))), // Лев
array((int)date('z', mktime(1,1,1, 8, 24, $_t[2])), (int)date('z', mktime(1,1,1, 9, 23, $_t[2]))), // Дева
array((int)date('z', mktime(1,1,1, 9, 24, $_t[2])), (int)date('z', mktime(1,1,1, 10, 23, $_t[2]))), // Весы
array((int)date('z', mktime(1,1,1, 10, 24, $_t[2])), (int)date('z', mktime(1,1,1, 11, 22, $_t[2]))), // Скорпион
array((int)date('z', mktime(1,1,1, 11, 23, $_t[2])), (int)date('z', mktime(1,1,1, 12, 21, $_t[2]))), // Стрелец
array((int)date('z', mktime(1,1,1, 12, 22, $_t[2])), (int)date('z', mktime(1,1,1, 1, 20, $_t[2]))), // Козерог
array((int)date('z', mktime(1,1,1, 1, 21, $_t[2])), (int)date('z', mktime(1,1,1, 2, 20, $_t[2]))), // Водолей
array((int)date('z', mktime(1,1,1, 2, 21, $_t[2])), (int)date('z', mktime(1,1,1, 3, 20, $_t[2])))); // Рыбы
foreach($_z as $_i=>$_m) {
if ($_i) {
if ($_i==10 && ($_d>=$_m[0] || $_d<=$_m[1])) return $_i;
if ($_d>=$_m[0] && $_d<=$_m[1]) return $_i;
}
}
return 0;
}
?>
|