Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
Itinerary
Commits
084cddf1
Commit
084cddf1
authored
Nov 21, 2021
by
Volker Krause
Browse files
NL CoronaCheck certificates specify no birth year, show that correctly
parent
6a5710cd
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/app/HealthCertificateRecovery.qml
View file @
084cddf1
...
...
@@ -34,7 +34,7 @@ ColumnLayout {
Kirigami.FormData.label
:
i18n
(
"
Name:
"
)
}
QQC2.Label
{
text
:
certificate
.
dateOfBirth
.
toLocaleDateString
(
Qt
.
locale
(),
Locale
.
ShortFormat
)
text
:
Localizer
.
formatDate
(
certificate
,
"
dateOfBirth
"
)
visible
:
!
isNaN
(
certificate
.
dateOfBirth
.
getTime
())
Kirigami.FormData.label
:
i18n
(
"
Date of birth:
"
)
}
...
...
src/app/HealthCertificateTest.qml
View file @
084cddf1
...
...
@@ -34,7 +34,7 @@ ColumnLayout {
Kirigami.FormData.label
:
i18n
(
"
Name:
"
)
}
QQC2.Label
{
text
:
certificate
.
dateOfBirth
.
toLocaleDateString
(
Qt
.
locale
(),
Locale
.
ShortFormat
)
text
:
Localizer
.
formatDate
(
certificate
,
"
dateOfBirth
"
)
visible
:
!
isNaN
(
certificate
.
dateOfBirth
.
getTime
())
Kirigami.FormData.label
:
i18n
(
"
Date of birth:
"
)
}
...
...
src/app/HealthCertificateVaccination.qml
View file @
084cddf1
...
...
@@ -37,7 +37,7 @@ ColumnLayout {
Kirigami.FormData.label
:
i18n
(
"
Name:
"
)
}
QQC2.Label
{
text
:
certificate
.
dateOfBirth
.
toLocaleDateString
(
Qt
.
locale
(),
Locale
.
ShortFormat
)
text
:
Localizer
.
formatDate
(
certificate
,
"
dateOfBirth
"
)
visible
:
!
isNaN
(
certificate
.
dateOfBirth
.
getTime
())
Kirigami.FormData.label
:
i18n
(
"
Date of birth:
"
)
}
...
...
src/app/localizer.cpp
View file @
084cddf1
...
...
@@ -134,6 +134,19 @@ QString Localizer::formatTime(const QVariant &obj, const QString &propertyName)
return
s
;
}
QString
Localizer
::
formatDate
(
const
QVariant
&
obj
,
const
QString
&
propertyName
)
const
{
const
auto
dt
=
JsonLdDocument
::
readProperty
(
obj
,
propertyName
.
toUtf8
().
constData
()).
toDate
();
if
(
!
dt
.
isValid
())
{
return
{};
}
if
(
dt
.
year
()
<=
1900
)
{
// no year specified
return
dt
.
toString
(
QStringLiteral
(
"dd MMMM"
));
// TODO i18n in master
}
return
QLocale
().
toString
(
dt
,
QLocale
::
ShortFormat
);
}
QString
Localizer
::
formatDateTime
(
const
QVariant
&
obj
,
const
QString
&
propertyName
)
const
{
const
auto
dt
=
JsonLdDocument
::
readProperty
(
obj
,
propertyName
.
toUtf8
().
constData
()).
toDateTime
();
...
...
src/app/localizer.h
View file @
084cddf1
...
...
@@ -26,6 +26,7 @@ public:
Q_INVOKABLE
QString
countryFlag
(
const
QString
&
isoCode
)
const
;
Q_INVOKABLE
QString
formatAddress
(
const
QVariant
&
obj
)
const
;
Q_INVOKABLE
QString
formatTime
(
const
QVariant
&
obj
,
const
QString
&
propertyName
)
const
;
Q_INVOKABLE
QString
formatDate
(
const
QVariant
&
obj
,
const
QString
&
propertyName
)
const
;
Q_INVOKABLE
QString
formatDateTime
(
const
QVariant
&
obj
,
const
QString
&
propertyName
)
const
;
Q_INVOKABLE
QString
formatDuration
(
int
seconds
)
const
;
Q_INVOKABLE
QString
formatDistance
(
int
meter
)
const
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment