-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
abraflexi-monthdigest.php
50 lines (42 loc) · 1.63 KB
/
abraflexi-monthdigest.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
<?php
declare(strict_types=1);
/**
* This file is part of the AbraFlexi-Digest package
*
* https://github.com/VitexSoftware/AbraFlexi-Digest/
*
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace AbraFlexi\Digest;
\define('EASE_APPNAME', 'AbraFlexi 🌜 Mothly Digest');
require_once __DIR__.'/init.php';
$start = new \DateTime();
$start->modify('-1 month');
$end = new \DateTime();
$period = new \DatePeriod($start, new \DateInterval('P1D'), $end);
$fmt = datefmt_create(
'cs_CZ',
\IntlDateFormatter::SHORT,
\IntlDateFormatter::NONE,
'Europe/Prague',
\IntlDateFormatter::GREGORIAN,
);
$myCompany = new \AbraFlexi\Company(\Ease\Shared::cfg('ABRAFLEXI_COMPANY'));
$myCompanyName = $myCompany->getDataValue('nazev');
$subject = sprintf(
_('AbraFlexi %s 🌜 monthly digest from %s to %s'),
$myCompanyName,
\datefmt_format($fmt, $period->getStartDate()->getTimestamp()),
\datefmt_format($fmt, $period->getEndDate()->getTimestamp()),
);
$digestor = new Digestor($subject);
$formatter = new \IntlDateFormatter(\Ease\Locale::$localeUsed, \IntlDateFormatter::LONG, \IntlDateFormatter::NONE);
$digestor->addItem(new \Ease\Html\DivTag(sprintf(
_('from %s to %s'),
$formatter->format($period->getStartDate()->getTimestamp()),
$formatter->format($period->getEndDate()->getTimestamp()),
)));
$digestor->dig($period, array_merge(\Ease\Functions::loadClassesInNamespace('AbraFlexi\Digest\Modules'), \Ease\Functions::loadClassesInNamespace('AbraFlexi\Digest\Modules\Monthly')));