chore: always publish time in RFC 3339 (#5886)

This commit is contained in:
andig 2023-01-24 18:43:38 +01:00 • committed by GitHub
parent f0f1f8c299
commit 72121dbcfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 6 deletions

View file

@ -123,7 +123,7 @@
<small>
{{
$t("footer.savings.since", {
since: fmtDayMonthYear(startDate),
since: startDate,
})
}}
</small>
@ -157,7 +157,7 @@ export default {
mixins: [formatter],
props: {
selfConsumptionPercent: Number,
since: { type: Number, default: 0 },
since: String,
sponsor: String,
amount: { type: Number, default: 0 },
effectivePrice: { type: Number, default: 0 },
@ -182,7 +182,10 @@ export default {
return { value, unit };
},
startDate() {
return new Date(this.since * 1000);
if (this.since) {
return this.fmtDayMonthYear(new Date(this.since));
}
return "";
},
},
methods: {

View file

@ -75,7 +75,7 @@ export default {
savingsGridCharged: Number,
savingsSelfConsumptionCharged: Number,
savingsSelfConsumptionPercent: Number,
savingsSince: Number,
savingsSince: String,
savingsTotalCharged: Number,
tariffFeedIn: Number,
tariffGrid: Number,

View file

@ -586,7 +586,7 @@ func (site *Site) prepare() {
site.publish("residualPower", site.ResidualPower)
site.publish("currency", site.tariffs.Currency.String())
site.publish("savingsSince", site.savings.Since().Unix())
site.publish("savingsSince", site.savings.Since())
site.publish("vehicles", vehicleTitles(site.GetVehicles()))
}

View file

@ -94,7 +94,7 @@ func encode(v interface{}) (string, error) {
case time.Time:
var b []byte
if !val.IsZero() {
b, _ = val.MarshalText()
b, _ = val.Round(time.Second).Local().MarshalText()
}
s = fmt.Sprintf(`"%s"`, string(b))
case time.Duration: