Handle invalid date in saveMany (#56)
parent
373d37ecf1
commit
f108c31d67
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -292,7 +292,13 @@ export default class EditDate extends Mixins(GlobalMixin) {
|
||||||
// Create PATCH requests
|
// Create PATCH requests
|
||||||
const calls = this.photos.map((p) => async () => {
|
const calls = this.photos.map((p) => async () => {
|
||||||
try {
|
try {
|
||||||
const pDate = new Date(p.datetaken);
|
let pDate = new Date(p.datetaken);
|
||||||
|
|
||||||
|
// Fallback to start date if invalid date
|
||||||
|
if (isNaN(pDate.getTime())) {
|
||||||
|
pDate = date;
|
||||||
|
}
|
||||||
|
|
||||||
const offset = date.getTime() - pDate.getTime();
|
const offset = date.getTime() - pDate.getTime();
|
||||||
const pDateNew = new Date(dateNew.getTime() - offset * (diffNew / diff));
|
const pDateNew = new Date(dateNew.getTime() - offset * (diffNew / diff));
|
||||||
const res = await axios.patch<any>(generateUrl(EDIT_API_URL, { id: p.fileid }), {
|
const res = await axios.patch<any>(generateUrl(EDIT_API_URL, { id: p.fileid }), {
|
||||||
|
|
Loading…
Reference in New Issue