Skip to content

Commit

Permalink
Merge pull request #8 from JakubZojdzik/develop
Browse files Browse the repository at this point in the history
Fix timezone
  • Loading branch information
maciejopalinski authored Apr 21, 2024
2 parents 69609e6 + 53f1122 commit 659fc31
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/components/UserTileItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export default {
props: {
name: String,
points: Number,
points: String,
position: Number,
active: Boolean
}
Expand Down
2 changes: 1 addition & 1 deletion src/views/AddAnnouncementView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default {
title: this.title,
content: this.content,
author: this.author,
added: this.added
added: new Date(this.added).toISOString()
},
{
headers: {
Expand Down
2 changes: 1 addition & 1 deletion src/views/AddChallengeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default {
answer: this.answer,
author: this.author,
points: this.points,
start: this.start
start: new Date(this.start).toISOString()
},
{
headers: {
Expand Down
4 changes: 2 additions & 2 deletions src/views/AnnouncementsView.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script>
import axios from 'axios';
import dateFormat from 'dateformat';
import VueCookie from 'vue-cookie';
import { useAdmin } from '../composables';
import { AnnouncementItem } from '../components';
Expand Down Expand Up @@ -35,7 +34,8 @@ export default {
});
this.ann = this.ann.concat(inactAnn);
this.ann.forEach((el) => {
el.added = dateFormat(el.added, 'dd-mm-yyyy, HH:MM:ss', true);
el.added = new Date(el.added);
el.added = el.added.toLocaleString('pl-PL');
});
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/views/ChallengeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default {
this.author = chall.author;
this.points = chall.points;
this.solves = chall.solves;
this.start = chall.start;
this.start = new Date(chall.start).toLocaleString('pl-PL');
this.solved = s.includes(this.id);
this.error = '';
},
Expand Down
6 changes: 4 additions & 2 deletions src/views/EditAnnouncementView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default {
title: this.title,
content: this.content,
author: this.author,
added: this.added,
added: new Date(this.added).toISOString(),
annId: this.id
},
{
Expand Down Expand Up @@ -63,7 +63,9 @@ export default {
this.title = ann.title;
this.content = ann.content;
this.author = ann.author;
this.added = ann.added.slice(0, -1);
ann.added = new Date(ann.added);
this.added = (new Date(ann.added.getTime() - ann.added.getTimezoneOffset() * 60000).toISOString()).slice(0, -1);
}
},
mounted() {
Expand Down
6 changes: 4 additions & 2 deletions src/views/EditChallengeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default {
author: this.author,
points: this.points,
solves: this.solves,
start: this.start,
start: new Date(this.start).toISOString(),
challId: this.id
},
{
Expand Down Expand Up @@ -83,7 +83,9 @@ export default {
this.author = chall.author;
this.points = chall.points;
this.solves = chall.solves;
this.start = chall.start.slice(0, -1);
this.start = new Date(chall.start);
this.start = (new Date(this.start.getTime() - this.start.getTimezoneOffset() * 60000).toISOString()).slice(0, -1);
}
},
mounted() {
Expand Down
16 changes: 10 additions & 6 deletions src/views/EditCompetitionView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export default {
{
title: this.title,
rules: this.rules,
start: this.start,
end: this.end,
start: new Date(this.start).toISOString(),
end: new Date(this.end).toISOString(),
freeze: this.freeze,
freezeTime: this.freezeTime
freezeTime: new Date(this.freezeTime).toISOString()
},
{
headers: {
Expand Down Expand Up @@ -66,10 +66,14 @@ export default {
const tr = (await axios.get(`${url}/competition/timeRange`)).data;
this.title = (await axios.get(`${url}/competition/title`)).data;
this.rules = (await axios.get(`${url}/competition/rules`)).data;
this.start = tr.start;
this.end = tr.end;
this.start = new Date(tr.start);
this.end = new Date(tr.end);
this.freeze = (await axios.get(`${url}/competition/freeze`)).data;
this.freezeTime = (await axios.get(`${url}/competition/freezeTime`)).data;
this.freezeTime = new Date((await axios.get(`${url}/competition/freezeTime`)).data);
this.start = (new Date(this.start.getTime() - this.start.getTimezoneOffset() * 60000).toISOString()).slice(0, -1);
this.end = (new Date(this.end.getTime() - this.end.getTimezoneOffset() * 60000).toISOString()).slice(0, -1);
this.freezeTime = (new Date(this.freezeTime.getTime() - this.freezeTime.getTimezoneOffset() * 60000).toISOString()).slice(0, -1);
} catch (error) {
if (error.response.status === 404 || error.response.status === 400) {
this.$router.push('/NotFound');
Expand Down

0 comments on commit 659fc31

Please sign in to comment.