Permalink
Browse files

Use intldateformatter for getting day/month names instead of relying …

…on locales
  • Loading branch information...
flack committed Nov 3, 2017
1 parent 4c9863b commit 58373971d466bba81f76d570508e56c9889f440f
@@ -70,6 +70,13 @@ public function datetime($value = null, $dateformat = 'medium', $timeformat = 's
return $this->date($value, $dateformat, $timeformat);
}
public function customdate($value, $pattern)
{
$formatter = new IntlDateFormatter($this->get_locale(), IntlDateFormatter::FULL, IntlDateFormatter::FULL);
$formatter->setPattern($pattern);
return $formatter->format($value);
}
public function timeframe($start, $end, $mode = 'both', $range_separator = null, $fulldate = false)
{
$ranger = new Ranger($this->get_locale());
@@ -200,9 +200,10 @@ private function _compute_welcome_data()
private function _get_month_names()
{
$names = [];
$formatter = $this->_l10n->get_formatter();
for ($i = 1; $i < 13; $i++) {
$timestamp = mktime(0, 0, 0, $i, 1, 2011);
$names[$i] = strftime('%B', $timestamp);
$names[$i] = $formatter->customdate($timestamp, 'MMMM');
}
return $names;
}
@@ -9,7 +9,7 @@
$i = 6;
while ($time < $data['week_end']) {
$date_identifier = date('Y-m-d', $time);
$data['grid']->set_column($date_identifier, strftime('%a', $time), 'fixed: true, headerTitle: "' . $formatter->date($time) . '" , width: 40, summaryType: calculate_subtotal, align: "right"', 'float');
$data['grid']->set_column($date_identifier, $formatter->customdate($time, 'E'), 'fixed: true, headerTitle: "' . $formatter->date($time) . '" , width: 40, summaryType: calculate_subtotal, align: "right"', 'float');
// Hop to next day
$date_columns[] = $date_identifier;
$time = $time + 3600 * 24;
@@ -51,7 +51,7 @@ public function get_row(midcom_core_dbaobject $at_entry)
{
$invoice = [
'time' => strftime('%Y-%m-%d %H:%M:%S', $at_entry->start),
'month' => strftime('%B %Y', $at_entry->start),
'month' => $this->_l10n->get_formatter()->customdate($at_entry->start, 'MMMM y'),
'index_month' => strftime('%Y-%m', $at_entry->start),
];
try {
@@ -1,6 +1,7 @@
<?php
$prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX);
$l10n = midcom::get()->i18n->get_l10n('org.openpsa.invoices');
$formatter = $l10n->get_formatter();
$status_options = [
'scheduled' => $l10n->get('scheduled'),
@@ -62,7 +63,7 @@
if ($invoice->{$data['date_field']} > 0) {
$entry['date'] = strftime('%Y-%m-%d', $invoice->{$data['date_field']});
$entry['year'] = strftime('%Y', $invoice->{$data['date_field']});
$entry['month'] = strftime('%B %Y', $invoice->{$data['date_field']});
$entry['month'] = $formatter->customdate($invoice->{$data['date_field']}, 'MMMM y');
$entry['index_month'] = strftime('%Y%m', $invoice->{$data['date_field']});
}
try {

0 comments on commit 5837397

Please sign in to comment.