Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
feat: add local time component (#661)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbarnsley committed Sep 24, 2021
1 parent 751baab commit ea547e6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
23 changes: 23 additions & 0 deletions resources/views/local-time.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@props([
'datetime',
'format',
'placeholder' => null,
'tooltipFormat' => null,
])

<span
x-data="{
datetime: dayjs({{ $datetime->timestamp }} * 1000),
format: '{{ $format }}',
output: '{{ $placeholder }}',
tooltip: null,
}"
x-init="
output = datetime.format(format);
@if($tooltipFormat)
tooltip = datetime.format('{{ $tooltipFormat }}');
@endif
"
x-text="output"
:data-tippy-content="tooltip"
></span>
8 changes: 8 additions & 0 deletions src/Support/DateFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,12 @@ class DateFormat
const TIME_SHORT = 'd M Y H:i';

const TIME_PARENTHESES = 'd M Y (H:i:s)';

const DATE_JS = 'D MMM YYYY';

const TIME_JS = 'D MMM YYYY HH:mm:ss';

const TIME_SHORT_JS = 'D MMM YYYY HH:mm';

const TIME_PARENTHESES_JS = 'D MMM YYYY (HH:mm:ss)';
}
1 change: 1 addition & 0 deletions src/UserInterfaceServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ private function registerBladeComponents(): void
Blade::component('ark::image-tile', 'ark-image-tile');
Blade::component('ark::info', 'ark-info');
Blade::component('ark::js-modal', 'ark-js-modal');
Blade::component('ark::local-time', 'ark-local-time');
Blade::component('ark::logo', 'ark-logo');
Blade::component('ark::logo-simple', 'ark-logo-simple');
Blade::component('ark::loading-spinner', 'ark-loading-spinner');
Expand Down

0 comments on commit ea547e6

Please sign in to comment.