2017-08-28 19:15:47 +02:00
|
|
|
const dateTimeOptions = {
|
|
|
|
day: '2-digit',
|
|
|
|
month: '2-digit',
|
|
|
|
year: 'numeric',
|
|
|
|
hour: '2-digit',
|
|
|
|
minute: '2-digit',
|
|
|
|
second: '2-digit',
|
2018-02-07 14:25:02 +01:00
|
|
|
};
|
2018-02-08 12:57:36 +01:00
|
|
|
export const formatFullDateTimeWithLocale = (v, locale, tz) => {
|
|
|
|
if (tz) {
|
|
|
|
dateTimeOptions.timeZone = tz;
|
|
|
|
}
|
2018-02-07 14:25:02 +01:00
|
|
|
return new Date(v).toLocaleString(locale, dateTimeOptions);
|
2017-08-28 19:15:47 +02:00
|
|
|
};
|
2020-02-27 21:36:07 +01:00
|
|
|
|
|
|
|
export const trim = value => {
|
|
|
|
if (value && value.trim) {
|
|
|
|
return value.trim();
|
|
|
|
} else {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
};
|
2020-05-20 16:32:29 +02:00
|
|
|
|
|
|
|
export function updateWeight(variants, totalWeight) {
|
|
|
|
const size = variants.length;
|
|
|
|
const percentage = parseInt((1 / size) * totalWeight);
|
|
|
|
|
|
|
|
variants.forEach(v => {
|
|
|
|
v.weight = percentage;
|
|
|
|
});
|
|
|
|
return variants;
|
|
|
|
}
|