Skip to content

Commit

Permalink
Addresses #1064 going forward (#1071)
Browse files Browse the repository at this point in the history
* Addresses #1064 going forward by making all timestamps based on the start of the day utc not the local time

* Group details: save date with correct utc timezone.

Co-authored-by: corsacca <[email protected]>
  • Loading branch information
micahmills and corsacca committed Nov 2, 2020
1 parent 7e5d470 commit 21a39ab
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dt-assets/js/details.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jQuery(document).ready(function($) {
date = " ";//null;
}
let id = $(this).attr('id')
rest_api.update_post( post_type, post_id, { [id]: moment(date).unix() }).then((resp)=>{
rest_api.update_post( post_type, post_id, { [id]: moment.utc(date).unix() }).then((resp)=>{
if (this.value) {
this.value = window.SHAREDFUNCTIONS.formatDate(resp[id]["timestamp"]);
}
Expand Down
2 changes: 1 addition & 1 deletion dt-assets/js/group-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ jQuery(document).ready(function($) {
date = $(val).val();
}
let id = $(val).attr('id')
API.update_post( 'groups', groupId, { [id]: moment(date).unix() }).then((resp)=>{
API.update_post( 'groups', groupId, { [id]: moment.utc(date).unix() }).then((resp)=>{
if (val.value) {
$(val).val(moment.unix(resp[id]["timestamp"]).format("YYYY-MM-DD"));
}
Expand Down
5 changes: 4 additions & 1 deletion dt-assets/js/shared-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,11 @@ window.SHAREDFUNCTIONS = {
if ( with_time ){
options.hour = 'numeric'
options.minute = 'numeric'
} else {
options.timeZone = 'UTC';
}
const formattedDate = new Intl.DateTimeFormat(langcode, options).format(date * 1000);

const formattedDate = new Intl.DateTimeFormat(langcode, options).format(date*1000);

return formattedDate;
},
Expand Down

0 comments on commit 21a39ab

Please sign in to comment.