-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
♻️ : create specific date time vue filter with vanilly instead of moment
- Loading branch information
1 parent
429ffb3
commit 3f4381a
Showing
6 changed files
with
38 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/resources/templates/vue_templates/filters/date-time.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<script> | ||
function formatDate(value, options) { | ||
if (!value) return ''; | ||
return new Intl.DateTimeFormat(undefined, options).format(Date.parse(value)); | ||
} | ||
// display date like "05/04/2020, 4:20:20 AM" | ||
Vue.filter('dateTime', function (value) { | ||
return formatDate(value, { | ||
"day": "2-digit", | ||
"month": "2-digit", | ||
"year": "numeric", | ||
"hour": "numeric", | ||
"minute": "2-digit", | ||
"second": "2-digit" | ||
}); | ||
}); | ||
// display date like "May 04, 2020, 4:20:20 AM" | ||
Vue.filter('dateTimeLong', function (value) { | ||
return formatDate(value, { | ||
"day": "2-digit", | ||
"month": "long", | ||
"year": "numeric", | ||
"hour": "numeric", | ||
"minute": "2-digit", | ||
"second": "2-digit" | ||
}); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters