Stamp dates correctly in DB
Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
parent
8871ffa28e
commit
33b8c0a65b
@ -567,7 +567,7 @@
|
||||
// thumbnail.width = this.calcWidth;
|
||||
thumbnail.addEventListener("load-image", this._imageTap.bind(this));
|
||||
thumbnail.addEventListener("load-album", this.loadAlbum.bind(this));
|
||||
datetime = (photo.taken || photo.modified || photo.added).replace(/T.*$/, "");
|
||||
datetime = new Date((photo.taken || photo.modified || photo.added) + " GMT").toISOString().replace(/T.*$/, "");
|
||||
|
||||
var dateBlock = this.querySelector("#date-" + datetime), thumbnails;
|
||||
if (!dateBlock) {
|
||||
|
@ -362,16 +362,31 @@ function triggerWatcher() {
|
||||
replacements.taken = replacements.modified = moment(created).format();
|
||||
}
|
||||
} else {
|
||||
let patterns = /(20[0-9][0-9]-?[0-9][0-9]-?[0-9][0-9])[_\-]?([0-9]*)/, date = moment(created).format();
|
||||
/* Attempt to infer the datestamp from the filename */
|
||||
let patterns = /WhatsApp Image (20[0-9][0-9]-[0-9][0-9]-[0-9][0-9]) at (.*).(jpeg|jpg)/;
|
||||
let date = moment(created).format();
|
||||
let match = file.match(patterns);
|
||||
if (match) {
|
||||
date = moment((match[1]+" "+match[2]), "YYYY-MM-DD h.mm.ss a").format();
|
||||
if (date == "Invalid date") {
|
||||
date = moment(created).format();
|
||||
}
|
||||
} else {
|
||||
patterns = /(20[0-9][0-9]-?[0-9][0-9]-?[0-9][0-9])[_\-]?([0-9]{6})?/;
|
||||
match = file.match(patterns);
|
||||
if (match) {
|
||||
if (match[2]) { /* Stamp had time in it */
|
||||
date = moment((match[1]+""+match[2]).replace(/-/g, ""), "YYYYMMDDHHmmss").format();
|
||||
} else {
|
||||
date = moment(match[1].replace(/-/g, ""), "YYYYMMDD").format();
|
||||
}
|
||||
if (date == "Invalid date") {
|
||||
date = moment(created).format();
|
||||
}
|
||||
} else {
|
||||
date = moment(created).format();
|
||||
}
|
||||
}
|
||||
replacements.taken = replacements.modified = date;
|
||||
}
|
||||
|
||||
@ -386,7 +401,7 @@ function triggerWatcher() {
|
||||
return resize.then(function() {
|
||||
return photoDB.sequelize.query("INSERT INTO photos " +
|
||||
"(albumId,path,filename,added,modified,taken,width,height,name)" +
|
||||
"VALUES(:albumId,:path,:filename,DATE(:added),DATE(:modified),DATE(:taken),:width,:height,:name)", {
|
||||
"VALUES(:albumId,:path,:filename,DATETIME(:added),DATETIME(:modified),DATETIME(:taken),:width,:height,:name)", {
|
||||
replacements: replacements
|
||||
});
|
||||
}).catch(function(error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user