-
Notifications
You must be signed in to change notification settings - Fork 16
/
temporal2.php
executable file
·84 lines (71 loc) · 2.52 KB
/
temporal2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php /*
ocPortal
Copyright (c) ocProducts, 2004-2012
See text/EN/licence.txt for full licencing information.
NOTE TO PROGRAMMERS:
Do not edit this file. If you need to make changes, save your changed file to the appropriate *_custom folder
**** If you ignore this advice, then your website upgrades (e.g. for bug fixes) will likely kill your changes ****
*/
/**
* @license http://opensource.org/licenses/cpal_1.0 Common Public Attribution License
* @copyright ocProducts Ltd
* @package core
*/
/**
* Check a POST inputted date for validity, and get the Unix timestamp for the inputted date.
*
* @param ID_TEXT The stub of the parameter name (stub_year, stub_month, stub_day, stub_hour, stub_minute)
* @param boolean Whether to allow over get parameters also
* @param boolean Whether to do timezone conversion
* @return ?TIME The timestamp of the date (NULL: no input date was chosen)
*/
function _get_input_date($stub,$get_also=false,$do_timezone_conversion=true)
{
$timezone=post_param('timezone',get_users_timezone());
if ($get_also)
{
// if (either_param_integer($stub,0)==0) return NULL; // NULL was chosen Doesn't work like this now
$year=either_param_integer($stub.'_year',NULL);
if (is_null($year)) return NULL;
$month=either_param_integer($stub.'_month',NULL);
if (is_null($month)) return NULL;
$day=either_param_integer($stub.'_day',NULL);
if (is_null($day)) return NULL;
$hour=either_param_integer($stub.'_hour',NULL);
$minute=either_param_integer($stub.'_minute',NULL);
} else
{
// if (post_param_integer($stub,0)==0) return NULL; // NULL was chosen Doesn't work like this now
$year=post_param_integer($stub.'_year',NULL);
if (is_null($year)) return NULL;
$month=post_param_integer($stub.'_month',NULL);
if (is_null($month)) return NULL;
$day=post_param_integer($stub.'_day',NULL);
if (is_null($day)) return NULL;
$hour=post_param_integer($stub.'_hour',NULL);
$minute=post_param_integer($stub.'_minute',NULL);
}
if (!checkdate($month,$day,$year)) warn_exit(do_lang_tempcode('INVALID_DATE_GIVEN'));
if (is_null($hour))
{
if (strpos($stub,'end')!==false)
{
$hour=23;
$minute=59;
} else
{
$hour=0;
$minute=0;
}
}
$time=mktime($hour,$minute,0,$month,$day,$year);
if ($do_timezone_conversion)
{
if (($year>=1970) || (@strftime('%Y',@mktime(0,0,0,1,1,1963))=='1963')) // Only try and do timezone conversion if we can do proper maths this far back
{
$amount_forward=tz_time($time,$timezone)-$time;
$time=$time-$amount_forward;
}
}
return $time;
}