Browse Source

logs-content: Changed adding adn editing to use browser's local time instead of UTC.

1.0
Gisle Aune 6 years ago
parent
commit
a098051733
  1. 8
      marko/page/logs-content/components/add-post-modal/component.js
  2. 2
      marko/page/logs-content/components/add-post-modal/index.marko
  3. 4
      marko/page/logs-content/components/edit-post-modal/component.js

8
marko/page/logs-content/components/add-post-modal/component.js

@ -8,14 +8,12 @@ module.exports = class {
error: null, error: null,
loading: false, loading: false,
values: { values: {
time: moment.utc(new Date()).format("YYYY-MM-DD HH:mm:ss"),
time: moment(new Date()).format("YYYY-MM-DD HH:mm:ss"),
kind: "text", kind: "text",
nick: "", nick: "",
text: "", text: "",
}, },
} }
this.first = false
} }
change(key, ev) { change(key, ev) {
@ -23,10 +21,10 @@ module.exports = class {
} }
open() { open() {
this.state.values.time = moment(new Date()).format("YYYY-MM-DD HH:mm:ss")
} }
close() { close() {
this.first = false
this.emit("close") this.emit("close")
} }
@ -37,7 +35,7 @@ module.exports = class {
const values = this.state.values const values = this.state.values
let time = new Date(values.time + " UTC")
let time = new Date(values.time)
if (Number.isNaN(time)) { if (Number.isNaN(time)) {
this.state.error = `Could not parse ${values.time} as date` this.state.error = `Could not parse ${values.time} as date`
return return

2
marko/page/logs-content/components/add-post-modal/index.marko

@ -17,7 +17,7 @@
</select> </select>
<label>Nick</label> <label>Nick</label>
<input key="nick" placeholder="IRC_Nick (You can use non-IRC letters here, like ', but I recommend you don't so the character is found)" class="big" on-change("change", "nick") value=state.values.nick />
<input key="nick" placeholder="IRC_Nick" class="big" on-change("change", "nick") value=state.values.nick />
<label>Text</label> <label>Text</label>
<textarea key="text" placeholder="Text" class="tall" on-change("change", "text") value=state.values.text /> <textarea key="text" placeholder="Text" class="tall" on-change("change", "text") value=state.values.text />

4
marko/page/logs-content/components/edit-post-modal/component.js

@ -21,7 +21,7 @@ module.exports = class {
onInput(input) { onInput(input) {
if (input.post) { if (input.post) {
const {kind, nick, text} = input.post const {kind, nick, text} = input.post
const time = moment.utc(input.post.time).format("YYYY-MM-DD HH:mm:ss")
const time = moment(input.post.time).format("YYYY-MM-DD HH:mm:ss")
this.state.values = {time, kind, nick, text} this.state.values = {time, kind, nick, text}
} }
@ -46,7 +46,7 @@ module.exports = class {
const values = this.state.values const values = this.state.values
let time = new Date(values.time + " UTC")
let time = new Date(values.time)
if (Number.isNaN(time)) { if (Number.isNaN(time)) {
this.state.error = `Could not parse ${values.time} as date` this.state.error = `Could not parse ${values.time} as date`
return return

Loading…
Cancel
Save