@@ 19-48 (lines=30) @@ | ||
16 | * |
|
17 | * @package Loom |
|
18 | */ |
|
19 | class Months extends AbstractUnit |
|
20 | { |
|
21 | /** |
|
22 | * @var null |
|
23 | */ |
|
24 | private $daysPerMonth = null; |
|
25 | ||
26 | ||
27 | /** |
|
28 | * @param int $value |
|
29 | * @param int|null $daysPerMonth |
|
30 | */ |
|
31 | public function __construct($value, $daysPerMonth = null) |
|
32 | { |
|
33 | parent::__construct($value); |
|
34 | ||
35 | $this->daysPerMonth = $daysPerMonth; |
|
36 | } |
|
37 | ||
38 | ||
39 | /** |
|
40 | * Return the months in milliseconds |
|
41 | * |
|
42 | * @return int |
|
43 | */ |
|
44 | public function toMilliseconds() |
|
45 | { |
|
46 | return $this->value * (is_null($this->daysPerMonth) ? 365 / 12 : $this->daysPerMonth) * 24 * 60 * 60 * 1000; |
|
47 | } |
|
48 | } |
|
49 |
@@ 19-47 (lines=29) @@ | ||
16 | * |
|
17 | * @package Loom |
|
18 | */ |
|
19 | class Years extends AbstractUnit |
|
20 | { |
|
21 | const SOLAR_DAYS = 365.2521897; |
|
22 | ||
23 | private $solar; |
|
24 | ||
25 | ||
26 | /** |
|
27 | * @param int $value |
|
28 | * @param bool $solar |
|
29 | */ |
|
30 | public function __construct($value, $solar = false) |
|
31 | { |
|
32 | parent::__construct($value); |
|
33 | ||
34 | $this->solar = $solar; |
|
35 | } |
|
36 | ||
37 | ||
38 | /** |
|
39 | * Return the years in milliseconds |
|
40 | * |
|
41 | * @return int |
|
42 | */ |
|
43 | public function toMilliseconds() |
|
44 | { |
|
45 | return $this->value * ($this->solar ? self::SOLAR_DAYS : 365) * 24 * 60 * 60 * 1000; |
|
46 | } |
|
47 | } |
|
48 |