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