mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-02 07:43:11 +03:00
🐛 fix date with seconds (#753)
closes #8603 - see https://github.com/TryGhost/Ghost/issues/8603#issuecomment-309538395 - see comment in code base
This commit is contained in:
parent
ff249689d5
commit
69b82b9207
@ -179,6 +179,24 @@ export default Model.extend(Comparable, ValidationEngine, {
|
||||
|
||||
if (publishedAtBlogDate && publishedAtBlogTime) {
|
||||
let publishedAtBlog = moment.tz(`${publishedAtBlogDate} ${publishedAtBlogTime}`, blogTimezone);
|
||||
|
||||
/**
|
||||
* Note:
|
||||
* If you create a post and publish it, we send seconds to the database.
|
||||
* If you edit the post afterwards, ember would send the date without seconds, because
|
||||
* the `publishedAtUTC` is based on `publishedAtBlogTime`, which is only in seconds.
|
||||
* The date time picker doesn't use seconds.
|
||||
*
|
||||
* This condition prevents the case:
|
||||
* - you edit a post, but you don't change the published_at time
|
||||
* - we keep the original date with seconds
|
||||
*
|
||||
* See https://github.com/TryGhost/Ghost/issues/8603#issuecomment-309538395.
|
||||
*/
|
||||
if (publishedAtBlog.diff(publishedAtUTC.clone().startOf('minutes')) === 0) {
|
||||
return publishedAtUTC;
|
||||
}
|
||||
|
||||
return publishedAtBlog;
|
||||
} else {
|
||||
return moment.tz(this.get('publishedAtUTC'), blogTimezone);
|
||||
@ -272,7 +290,6 @@ export default Model.extend(Comparable, ValidationEngine, {
|
||||
beforeSave() {
|
||||
let publishedAtBlogTZ = this.get('publishedAtBlogTZ');
|
||||
let publishedAtUTC = publishedAtBlogTZ ? publishedAtBlogTZ.utc() : null;
|
||||
|
||||
this.set('publishedAtUTC', publishedAtUTC);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user