comparison client/src/lib/filters.js @ 2541:468c8dc796cf

client: convert lib helper functions to Vue filters
author Markus Kottlaender <markus@intevation.de>
date Thu, 07 Mar 2019 15:53:12 +0100
parents
children add2d47c2567
comparison
equal deleted inserted replaced
2540:3c17d401fbd4 2541:468c8dc796cf
1 /* This is Free Software under GNU Affero General Public License v >= 3.0
2 * without warranty, see README.md and license for details.
3 *
4 * SPDX-License-Identifier: AGPL-3.0-or-later
5 * License-Filename: LICENSES/AGPL-3.0.txt
6 *
7 * Copyright (C) 2018 by via donau
8 * – Österreichische Wasserstraßen-Gesellschaft mbH
9 * Software engineering by Intevation GmbH
10 *
11 * Author(s):
12 * Thomas Junk <thomas.junk@intevation.de>
13 * Markus Kottländer <markus.kottlaender@intevation.de>
14 */
15
16 import locale2 from "locale2";
17
18 export default {
19 surveyDate(date) {
20 return date
21 ? new Date(date).toLocaleDateString(locale2, {
22 day: "2-digit",
23 month: "2-digit",
24 year: "numeric"
25 })
26 : "";
27 },
28 dateTime(date) {
29 if (!date) return "";
30 const d = new Date(date);
31 return (
32 d.toLocaleDateString(locale2, {
33 day: "2-digit",
34 month: "2-digit",
35 year: "numeric"
36 }) +
37 " - " +
38 d.toLocaleTimeString(locale2, {
39 hour12: false
40 })
41 );
42 }
43 };