Mercurial > gemma
annotate client/src/lib/date.js @ 2337:0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 19 Feb 2019 17:06:55 +0100 |
parents | 4dbed34f8738 |
children |
rev | line source |
---|---|
1525
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
1 /* This is Free Software under GNU Affero General Public License v >= 3.0 |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
2 * without warranty, see README.md and license for details. |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
3 * |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
4 * SPDX-License-Identifier: AGPL-3.0-or-later |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
5 * License-Filename: LICENSES/AGPL-3.0.txt |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
6 * |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
7 * Copyright (C) 2018 by via donau |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
8 * – Österreichische Wasserstraßen-Gesellschaft mbH |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
9 * Software engineering by Intevation GmbH |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
10 * |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
11 * Author(s): |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
12 * Thomas Junk <thomas.junk@intevation.de> |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
13 */ |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
14 |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
15 import locale2 from "locale2"; |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
16 |
1522 | 17 const formatSurveyDate = current => { |
18 return current | |
1525
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
19 ? new Date(current).toLocaleDateString(locale2, { |
1522 | 20 day: "2-digit", |
1525
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
21 month: "2-digit", |
4dbed34f8738
date localized according to browserlanguage
Thomas Junk <thomas.junk@intevation.de>
parents:
1522
diff
changeset
|
22 year: "numeric" |
1522 | 23 }) |
24 : ""; | |
25 }; | |
26 | |
2337
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
27 const formatDateTime = date => { |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
28 if (!date) return ""; |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
29 const d = new Date(date); |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
30 return ( |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
31 d.toLocaleDateString(locale2, { |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
32 day: "2-digit", |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
33 month: "2-digit", |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
34 year: "numeric" |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
35 }) + |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
36 " - " + |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
37 d.toLocaleTimeString(locale2, { |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
38 hour12: false |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
39 }) |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
40 ); |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
41 }; |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
42 |
0f3b0937e7c1
staging: format datetime instead of format date in AGM Diff View
Thomas Junk <thomas.junk@intevation.de>
parents:
1525
diff
changeset
|
43 export { formatSurveyDate, formatDateTime }; |