1: <?php
2:
3: 4: 5: 6: 7:
8:
9: namespace app\views\search;
10:
11: class Format
12: {
13:
14: public $utgave = array('1'=>'Morgen','2'=>'Formiddag', '3'=>'Ettermiddag','4'=>'Aften');
15:
16: public function formatDateToDBFormat($date)
17: {
18: $res = "";
19: $parts = explode (".",$date);
20: if (count ($parts) == 3)
21: {
22: $res = $parts[2].'-'.$parts[1].'-'.$parts[0];
23: }
24: return $res;
25: }
26:
27: public function formatDateToWebPageFormat($date)
28: {
29: $res = "";
30: $parts = explode ("-",$date);
31: if (count ($parts) == 3)
32: {
33: $res = $parts[2].'.'.$parts[1].'.'.$parts[0];
34: }
35: return $res;
36: }
37:
38: public function validateDateWebPageFormat($date)
39: {
40: $res = true;
41: $parts = explode ("-",$date);
42: if (count ($parts) != 3)
43: {
44: return false;
45: }
46: else
47: {
48: if (is_numeric($parts[0]) && is_numeric($parts[1]) && is_numeric($parts[2]))
49: {
50: if (checkdate($parts[1],$parts[2], $parts[0]))
51: {
52: if ($parts[0] > 1749 && $parts[0] < 2050)
53: return true;
54: else
55: return false;
56: }
57: else
58: {
59: return false;
60: }
61: }
62: else
63: {
64: return false;
65: }
66: }
67: return $res;
68: }
69: }
70:
71:
72: