mirror of
https://github.com/danpros/htmly.git
synced 2026-04-18 03:26:20 +05:30
Switch between date and IntlDateFormatter
This commit is contained in:
parent
10ca416f0e
commit
89b637e9f5
5 changed files with 42 additions and 26 deletions
|
|
@ -5,7 +5,7 @@ site.url = ""
|
||||||
timezone = "Asia/Jakarta"
|
timezone = "Asia/Jakarta"
|
||||||
|
|
||||||
; Date format. See: https://www.php.net/manual/en/function.strftime
|
; Date format. See: https://www.php.net/manual/en/function.strftime
|
||||||
date.format = "%d %B %Y"
|
date.format = "d F Y"
|
||||||
|
|
||||||
; Your language (example "en_US" for English or "de_DE" for German. See lang directory for available language)
|
; Your language (example "en_US" for English or "de_DE" for German. See lang directory for available language)
|
||||||
language = "en_US"
|
language = "en_US"
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,14 @@ if (login()) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
<?php if (!extension_loaded('zip')) { ?>
|
||||||
|
<div class="callout callout-info">
|
||||||
|
<h5><i class="fa fa-info"></i> Note:</h5>
|
||||||
|
Please install the ZIP extension to use the backup feature.
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
<h2><?php echo i18n('Your_backups');?></h2>
|
<h2><?php echo i18n('Your_backups');?></h2>
|
||||||
<br>
|
<br>
|
||||||
<a class="btn btn-primary" href="<?php echo site_url() ?>admin/backup-start"><?php echo i18n('Create_backup');?></a>
|
<a class="btn btn-primary <?php if (!extension_loaded('zip')) { ?>disabled<?php } ?>" href="<?php echo site_url() ?>admin/backup-start"><?php echo i18n('Create_backup');?></a>
|
||||||
<br><br>
|
<br><br>
|
||||||
<?php echo get_backup_files() ?>
|
<?php echo get_backup_files() ?>
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
<?php if (!defined('HTMLY')) die('HTMLy'); ?>
|
||||||
<h2><?php echo i18n('General_Settings')?></h2>
|
<h2><?php echo i18n('General_Settings')?></h2>
|
||||||
<br>
|
<br>
|
||||||
|
<?php if (!extension_loaded('intl')) { ?>
|
||||||
|
<div class="callout callout-info">
|
||||||
|
<h5><i class="fa fa-info"></i> Note:</h5>
|
||||||
|
Please install and enable the INTL extension to format the date format to your local language.
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
<nav>
|
<nav>
|
||||||
<div class="nav nav-tabs" id="nav-tab">
|
<div class="nav nav-tabs" id="nav-tab">
|
||||||
<a class="nav-item nav-link active" id="nav-general-tab" href="<?php echo site_url();?>admin/config"><?php echo i18n('General');?></a>
|
<a class="nav-item nav-link active" id="nav-general-tab" href="<?php echo site_url();?>admin/config"><?php echo i18n('General');?></a>
|
||||||
|
|
@ -66,45 +72,45 @@
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format1" value="dd MMMM yyyy" <?php if (config('date.format') === 'dd MMMM yyyy'):?>checked<?php endif;?>>
|
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format1" value="d F Y" <?php if (config('date.format') === 'd F Y'):?>checked<?php endif;?>>
|
||||||
<label class="form-check-label" for="date.format1">
|
<label class="form-check-label" for="date.format1">
|
||||||
<?php echo format_date(strtotime($date), 'dd MMMM yyyy'); ?>
|
<?php echo format_date(strtotime($date), 'd F Y'); ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format2" value="MMMM dd, yyyy" <?php if (config('date.format') === 'MMMM dd, yyyy'):?>checked<?php endif;?>>
|
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format2" value="F d, Y" <?php if (config('date.format') === 'F d, Y'):?>checked<?php endif;?>>
|
||||||
<label class="form-check-label" for="date.format2">
|
<label class="form-check-label" for="date.format2">
|
||||||
<?php echo format_date(strtotime($date), 'MMMM dd, yyyy'); ?>
|
<?php echo format_date(strtotime($date), 'F d, Y'); ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format3" value="dd MMM yyyy" <?php if (config('date.format') === 'dd MMM yyyy'):?>checked<?php endif;?>>
|
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format3" value="d M Y" <?php if (config('date.format') === 'd M Y'):?>checked<?php endif;?>>
|
||||||
<label class="form-check-label" for="date.format3">
|
<label class="form-check-label" for="date.format3">
|
||||||
<?php echo format_date(strtotime($date), 'dd MMM yyyy'); ?>
|
<?php echo format_date(strtotime($date), 'd M Y'); ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format4" value="MMM dd, yyyy" <?php if (config('date.format') === 'MMM dd, yyyy'):?>checked<?php endif;?>>
|
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format4" value="M d, Y" <?php if (config('date.format') === 'M d, Y'):?>checked<?php endif;?>>
|
||||||
<label class="form-check-label" for="date.format4">
|
<label class="form-check-label" for="date.format4">
|
||||||
<?php echo format_date(strtotime($date), 'MMM dd, yyyy'); ?>
|
<?php echo format_date(strtotime($date), 'M d, Y'); ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format5" value="dd/MM/yyyy" <?php if (config('date.format') === 'dd/MM/yyyy'):?>checked<?php endif;?>>
|
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format5" value="d/m/Y" <?php if (config('date.format') === 'd/m/Y'):?>checked<?php endif;?>>
|
||||||
<label class="form-check-label" for="date.format5">
|
<label class="form-check-label" for="date.format5">
|
||||||
<?php echo format_date(strtotime($date), 'dd/MM/yyyy'); ?>
|
<?php echo format_date(strtotime($date), 'd/m/Y'); ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format6" value="MM/dd/yyyy" <?php if (config('date.format') === 'MM/dd/yyyy'):?>checked<?php endif;?>>
|
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format6" value="m/d/Y" <?php if (config('date.format') === 'm/d/Y'):?>checked<?php endif;?>>
|
||||||
<label class="form-check-label" for="date.format6">
|
<label class="form-check-label" for="date.format6">
|
||||||
<?php echo format_date(strtotime($date), 'MM/dd/yyyy'); ?>
|
<?php echo format_date(strtotime($date), 'm/d/Y'); ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format6" value="yyyy-MM-dd" <?php if (config('date.format') === 'yyyy-MM-dd'):?>checked<?php endif;?>>
|
<input class="form-check-input" type="radio" name="-config-date.format" id="date.format6" value="Y-m-d" <?php if (config('date.format') === 'Y-m-d'):?>checked<?php endif;?>>
|
||||||
<label class="form-check-label" for="date.format6">
|
<label class="form-check-label" for="date.format6">
|
||||||
<?php echo format_date(strtotime($date), 'yyyy-MM-dd'); ?>
|
<?php echo format_date(strtotime($date), 'Y-m-d'); ?>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2072,9 +2072,9 @@ get('/archive/:req', function ($req) {
|
||||||
$date = strtotime($req);
|
$date = strtotime($req);
|
||||||
|
|
||||||
if (isset($time[0]) && isset($time[1]) && isset($time[2])) {
|
if (isset($time[0]) && isset($time[1]) && isset($time[2])) {
|
||||||
$timestamp = format_date($date, 'dd MMMM yyyy');
|
$timestamp = format_date($date, 'd F Y');
|
||||||
} elseif (isset($time[0]) && isset($time[1])) {
|
} elseif (isset($time[0]) && isset($time[1])) {
|
||||||
$timestamp = format_date($date, 'MMMM yyyy');
|
$timestamp = format_date($date, 'F Y');
|
||||||
} else {
|
} else {
|
||||||
$timestamp = $req;
|
$timestamp = $req;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1432,7 +1432,7 @@ EOF;
|
||||||
echo '<ul class="month">';
|
echo '<ul class="month">';
|
||||||
|
|
||||||
foreach ($by_month as $month => $count) {
|
foreach ($by_month as $month => $count) {
|
||||||
$name = format_date(mktime(0, 0, 0, $month, 1, 2010), 'MMMM');
|
$name = format_date(mktime(0, 0, 0, $month, 1, 2010), 'F');
|
||||||
echo '<li class="item"><a href="' . site_url() . 'archive/' . $year . '-' . $month . '">' . $name . '</a>';
|
echo '<li class="item"><a href="' . site_url() . 'archive/' . $year . '-' . $month . '">' . $name . '</a>';
|
||||||
echo ' <span class="count">(' . $count . ')</span></li>';
|
echo ' <span class="count">(' . $count . ')</span></li>';
|
||||||
}
|
}
|
||||||
|
|
@ -3251,15 +3251,19 @@ function get_language()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function format_date($date, $date_format = null)
|
function format_date($date, $dateFormat = null)
|
||||||
{
|
{
|
||||||
if (empty($date_format)) {
|
if (empty($dateFormat)) {
|
||||||
$date_format = config('date.format');
|
$dateFormat = config('date.format');
|
||||||
|
}
|
||||||
|
if (extension_loaded('intl')) {
|
||||||
|
$format_map = array('d' => 'dd', 'm' => 'MM', 'M' => 'MMM', 'F' => 'MMMM', 'Y' => 'yyyy');
|
||||||
|
$intlFormat = strtr($dateFormat, $format_map);
|
||||||
|
$formatter = new IntlDateFormatter(config('language'), IntlDateFormatter::NONE, IntlDateFormatter::NONE, config('timezone'), IntlDateFormatter::GREGORIAN, $intlFormat);
|
||||||
|
return $formatter->format($date);
|
||||||
|
} else {
|
||||||
|
return date($dateFormat, $date);
|
||||||
}
|
}
|
||||||
$formatter = new IntlDateFormatter(config('language'), IntlDateFormatter::LONG, IntlDateFormatter::NONE, config('timezone'), IntlDateFormatter::GREGORIAN, $date_format);
|
|
||||||
|
|
||||||
return $formatter->format($date);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function valueMaker($value)
|
function valueMaker($value)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue