1: <?php
2:
3: namespace Budabot\Core;
4:
5: use Exception;
6:
7: require_once 'SettingHandler.class.php';
8:
9: class TimeSettingHandler extends SettingHandler {
10:
11: public $util;
12:
13: public function __construct(DBRow $row) {
14: parent::__construct($row);
15: }
16:
17: 18: 19:
20: function displayValue() {
21: return "<highlight>" . $this->util->unixtimeToReadable($this->row->value) . "<end>";
22: }
23:
24: 25: 26:
27: function getDescription() {
28: $msg = "For this setting you must enter a time value. See <a href='chatcmd:///tell <myname> help budatime'>budatime</a> for info on the format of the 'time' parameter.\n\n";
29: $msg .= "To change this setting:\n\n";
30: $msg .= "<highlight>/tell <myname> settings save {$this->row->name} <i>time</i><end>\n\n";
31: return $msg;
32: }
33:
34: 35: 36:
37: function save($newValue) {
38: $time = $this->util->parseTime($newValue);
39: if ($time > 0) {
40: return $time;
41: } else {
42: throw new Exception("This is not a valid time for this setting.");
43: }
44: }
45: }
46: