Subversion Repositories Sigmater

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 Andrea 1
<?php
2
 
3
function mod($a,$b) {
4
 
5
	$x1 = (int) abs($a/$b);
6
   	$x2 = $a/$b;
7
   	return $a-($x1*$b);    
8
}    
9
 
10
function IsLeapYear($y) {
11
 
12
   	$bulis = ((mod($y,4) == 0) && ((mod ($y,100) <> 0) || (mod($y,400) == 0)));
13
   	return $bulis;
14
}
15
 
16
function daycount($dt) {
17
 
18
	$dc_year = (int) $dt['YY'];
19
   	$dc_month = (int) $dt['MM'];
20
 
21
	switch ($dc_month) {
22
 
23
		case  1:
24
		case  3:
25
		case  5:
26
		case  7:
27
		case  8:
28
		case 10:
29
		case 12: 
30
       		return 31;
31
		break;
32
 
33
		case  4:
34
		case  6:
35
		case  9:
36
		case 11: 
37
		       return 30;
38
		break; 
39
 
40
		case 2: 
41
			if (IsLeapYear($dc_year))
42
				return 29;
43
			else
44
				return 28;
45
		break;
46
	}
47
}
48
 
49
 
50
function split_sysdate() {
51
 
52
	global $sysdate;
53
 
54
	list($date, $time) = explode(' ', $sysdate);
55
 
56
	$arr_d = explode('/', $date);
57
	$arr_t = explode(':', $time);
58
 
59
	$arr_sysdate['DD'] = $arr_d[0];
60
	$arr_sysdate['MM'] = $arr_d[1];
61
	$arr_sysdate['YY'] = $arr_d[2];
62
	$arr_sysdate['HH'] = $arr_t[0];
63
	$arr_sysdate['MI'] = $arr_t[1];
64
	$arr_sysdate['SS'] = $arr_t[2];
65
 
66
	return $arr_sysdate;
67
}
68
 
69
function split_date($date) {
70
 
71
	$arr_d = explode('/', $date);
72
 
73
	$arr_date['DD'] = $arr_d[0];
74
	$arr_date['MM'] = $arr_d[1];
75
	$arr_date['YY'] = $arr_d[2];
76
 
77
	return $arr_date;
78
}
79
 
80
function sub_months($dt, $months) {
81
 
82
	$dt['MM'] = (int) $dt['MM'];
83
 
84
	if (($dt['MM'] - $months) < 1) {
85
 
86
		$dt['MM'] = $dt['MM'] + 12;
87
		$dt['YY'] = $dt['YY'] - 1;
88
 
89
	}	
90
 
91
	$dt['MM'] = str_pad($dt['MM'] - $months, 2, '0', STR_PAD_LEFT);
92
 
93
	return $dt;
94
}
95
 
96
?>