-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOccurrence.php
58 lines (52 loc) · 1.31 KB
/
Occurrence.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
<?php namespace ProcessWire;
use DateTime;
/**
* FieldtypeRecurringEvents: Occurrence
*
* An individual event item to be part of an OccurrenceArray for a Page
*
* @property DateTime $date Date string in Y-m-d format
* @property string $title Title of the event
* @property bool $formatted
*
*/
class Occurrence extends WireData {
/**
* Construct a new occurrence
*
*/
public function __construct() {
// define the fields that represent our event (and their default/blank values)
$this->set('date', '');
// $this->set('excluded', false);
$this->set('formatted', false);
$this->set('format', 'Y-m-d');
parent::__construct();
}
/**
* Set a value to the event: date, location or notes
*
* @param string $key
* @param DateTime $value
* @return WireData|self
*
*/
public function set($key, $value) {
/*if($key === 'excluded') {
$value = false;
}*/
return parent::set($key, $value);
}
public function format($format = "U"){
return $this->date->format($format);
}
/**
* Return a string representing this event
*
* @return string
*
*/
public function __toString() {
return $this->date->format($this->format);
}
}