mirror of
https://github.com/swissmakers/swiss-datashare.git
synced 2026-04-21 06:03:13 +02:00
* Started adding locale translations :) * Added some more translations * Working on translating even more pages * More translations * Added test default locale retrieval * replace `intl.formatMessage` with custom `t` hook * add more translations * improve title syntax * add more translations * translate admin config page * translated error messages * add language selecter * minor fixes * improve language handling * add upcoming languages * add `crowdin.yml` * run formatter --------- Co-authored-by: Steve Tautonico <stautonico@gmail.com>
33 lines
712 B
TypeScript
33 lines
712 B
TypeScript
import moment from "moment";
|
|
|
|
export const getExpirationPreview = (
|
|
messages: {
|
|
neverExpires: string;
|
|
expiresOn: string;
|
|
},
|
|
form: {
|
|
values: {
|
|
never_expires?: boolean;
|
|
expiration_num: number;
|
|
expiration_unit: string;
|
|
};
|
|
}
|
|
) => {
|
|
const value = form.values.never_expires
|
|
? "never"
|
|
: form.values.expiration_num + form.values.expiration_unit;
|
|
if (value === "never") return messages.neverExpires;
|
|
|
|
const expirationDate = moment()
|
|
.add(
|
|
value.split("-")[0],
|
|
value.split("-")[1] as moment.unitOfTime.DurationConstructor
|
|
)
|
|
.toDate();
|
|
|
|
return messages.expiresOn.replace(
|
|
"{expiration}",
|
|
moment(expirationDate).format("LLL")
|
|
);
|
|
};
|