-
Notifications
You must be signed in to change notification settings - Fork 0
/
Vevent.php
51 lines (40 loc) · 973 Bytes
/
Vevent.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
<?php
require(__DIR__ . '/Mail.php');
class Vevent
{
private $uid, $date, $title;
public function end ($str)
{
if (strcmp($str, 'END:VEVENT') != 0)
return false;
if ($this->uid && $this->date && $this->title)
$this->save();
return true;
}
public function uid ($str)
{
if (strncmp($str, 'COMMENT:', 8) != 0)
return false;
$this->uid = str_replace('https://www.calend.ru', '', substr($str, 8));
return true;
}
public function date ($str)
{
if (strncmp($str, 'DTSTART;VALUE=DATE:', 19) != 0)
return false;
$this->date = substr($str, 19);
return true;
}
public function title ($str)
{
if (strncmp($str, 'SUMMARY:', 8) != 0)
return false;
$this->title = substr($str, 8);
return true;
}
private function save ()
{
if (strcmp($this->date, date('Ymd')) === 0)
new Mail('[calend.ru date] ' . $this->title, date('d.m') . ': ' . $this->title);
}
}