# Wrong time when using the date picker: bug?

**URL:** https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520
**Category:** Bug
**Created:** [October 18, 2020, 3:23pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520 "2020-10-18T15:23:18Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![rgrunbla](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgrunbla/32/186169_2.png) [@rgrunbla](https://meta.discourse.org/u/rgrunbla)
#### Post date: [October 18, 2020, 3:23pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/1 "2020-10-18T15:23:18Z")

</div>

Hi,

My discourse ( 2.6.0.beta4 ) is configured with the Europe/Paris as the discourse local dates default timezones, but when I try to pick a time, the displayed time is wrong, as shown on this screenshot:

 ![foo](https://global.discourse-cdn.com/meta/original/3X/4/f/4fb782b82bcede7a250fb4f88c4af91688de5b67.png)

Even if I write “20:00:00”, the displayed time is “Today, 22:00”. The `moment.tz.guess()` executed in my browser gives “Europe/Paris”, so I don’t really guess what I’m doing wrong.

Any idea?

Thanks,

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [October 19, 2020, 2:08am UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/2 "2020-10-19T02:08:17Z")

</div>

@j.jaffeux any ideas on what could be causing this?

---

<div class="post-metadata">

### Author: ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)
#### Post date: [October 19, 2020, 9:09am UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/3 "2020-10-19T09:09:31Z")

</div>

I think it’s a bad handling of the french quotation mark (bbcode if I remember correctly) the case was addressed for the German locale

[https://meta.discourse.org/t/locale-date-timezone-cooking-error-with-french-localization/161532](https://meta.discourse.org/t/locale-date-timezone-cooking-error-with-french-localization/161532)

---

<div class="post-metadata">

### Author: ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)
#### Post date: [October 19, 2020, 9:14am UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/4 "2020-10-19T09:14:12Z")

</div>

I strip the tz of its quotation marks, not a long term solution, but… It works​😁

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [October 21, 2020, 2:10pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/5 "2020-10-21T14:10:01Z")

</div>

Yes sorry I was away Monday/Tuesday, I can’t repro locally but I think it’s the same case.

I went with this fix:

[https://github.com/discourse/discourse/pull/10986](https://github.com/discourse/discourse/pull/10986)

Technically this is more a pretty text/markdown bug than a local dates bug, we might want to have a more global solution to this. Although I have only had complaint of this in the local dates context, I guess it’s because it’s more used and more likely to be hand edited.

---

<div class="post-metadata">

### Author: ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)
#### Post date: [October 21, 2020, 2:28pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/6 "2020-10-21T14:28:50Z")

</div>

I don’t think it’s working, there might also be something about the condition line 99 of [discourse-local-dates.js.es6](https://github.com/discourse/discourse/blob/master/plugins/discourse-local-dates/assets/javascripts/lib/discourse-markdown/discourse-local-dates.js.es6)

```
if (config.timezone && moment.tz.names().includes(config.timezone))

```

which isn’t true (but should be).

edit  
I just realize the fix was committed on another branch, I’ll be back 😅  
… so no I checked,

```
[date=2020-12-20 time=15:00:00 timezone=„Europe/Paris“]
[date=2020-12-20 time=15:00:00 timezone=Europe/Paris]
[date=2020-12-20 time=15:00:00 timezone="Europe/Paris"]
[date=2020-12-20 time=15:00:00 timezone=«Europe/Paris»]

```

are right, right, wrong, wrong

---

<div class="post-metadata">

### Author: ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)
#### Post date: [October 21, 2020, 2:48pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/7 "2020-10-21T14:48:03Z")

</div>

And also, on my french azerty keyboard, the quotes are actually `"` I don’t even know how to make `«` or `»` without copy/paste, which is probably normal 🤔

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [October 21, 2020, 2:50pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/8 "2020-10-21T14:50:01Z")

</div>

I certainly don’t repro anything “wrong”:

 ![Screenshot 2020-10-21 at 16.49.23](https://global.discourse-cdn.com/meta/original/3X/b/4/b49028f1171d2b2e37a96daf363afed3c7be7380.png)

And this is the thing, you don’t actually write these quotes yourself, it’s some conversion happening.

---

<div class="post-metadata">

### Author: ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)
#### Post date: [October 21, 2020, 2:51pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/9 "2020-10-21T14:51:48Z")

</div>

It’s weird I have 16h00 for the last two

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [October 21, 2020, 2:53pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/10 "2020-10-21T14:53:00Z")

</div>

As you can repro the issue, could you try to add a log here: [https://github.com/discourse/discourse/blob/master/plugins/discourse-local-dates/assets/javascripts/lib/discourse-markdown/discourse-local-dates.js.es6#L15](https://github.com/discourse/discourse/blob/master/plugins/discourse-local-dates/assets/javascripts/lib/discourse-markdown/discourse-local-dates.js.es6#L15)

```javascript
console.log(matches[1]);

```

And show me exactly what you get.

---

<div class="post-metadata">

### Author: ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)
#### Post date: [October 21, 2020, 3:07pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/11 "2020-10-21T15:07:36Z")

</div>

well of course! but you lost me there 😄 I assume you’d like a rails log ? I really not an expert, just a bit enthusiast!  
And sorry, I misread a five for a six or I don’t know, the third one only doesn’t work, my bad, the fourth one doesn’t work in the preview but is right in the cooked post 🤪

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [October 21, 2020, 3:15pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/12 "2020-10-21T15:15:54Z")

</div>

I have pushed another pull request, maybe let’s wait this before you dig.

---

<div class="post-metadata">

### Author: ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)
#### Post date: [October 21, 2020, 3:28pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/13 "2020-10-21T15:28:02Z")

</div>

What I managed to see is that the attribute “data-timezone” is missing (when something doesn’t work)

```
Message

  Post Update (1.1ms) UPDATE "posts" SET "raw" = '[date=2020-12-20 time=12:00:00 timezone=Europe/Paris]
[date=2020-12-20 time=12:00:00 timezone="Europe/Paris"]', "self_edits" = 3, "cooked" = '<p><span data-date="2020-12-20" data-time="12:00:00" class="discourse-local-date" data-timezone="Europe/Paris" data-email-preview="2020-12-20T11:00:00Z UTC">2020-12-20T11:00:00Z</span><br>
<span data-date="2020-12-20" data-time="12:00:00" class="discourse-local-date" data-email-preview="2020-12-20T12:00:00Z UTC">2020-12-20T12:00:00Z</span></p>', "baked_at" = '2020-10-21 15:25:53.050518', "updated_at" = '2020-10-21 15:25:53.050721' WHERE "posts"."id" = 1954

```

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [October 21, 2020, 3:29pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/14 "2020-10-21T15:29:15Z")

</div>

yes because it doesn’t understand the converted quotes, this is why I’m trying to force them into a known state.

---

<div class="post-metadata">

### Author: ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)
#### Post date: [October 21, 2020, 3:46pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/15 "2020-10-21T15:46:14Z")

</div>

I’m sorry to even ask, I’ll let you work after that, I was under the impression that it was the `;` of the `\&laquo;` which makes  
`&& moment.tz.names().includes(config.timezone)` fails  
Could config.timezone be html escaped ?

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [October 21, 2020, 3:59pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/16 "2020-10-21T15:59:10Z")

</div>

No worries, I can totally be wrong 😃

So what you ask is basically what I do but not at the time you expect it, that could work too probably. So for example prior to my fix, something like:

```plaintext
[date=2020-12-20 time=15:00:00 timezone=«Europe/Paris»]

```

Would give these attributes in parsed markdown:

```plaintext
{"date"=>"2020-12-20", "time"=>"15:00:00", "timezone"=>"«Europe/Paris»"}

```

Which makes the issue obvious.

After my fix we get:

```plaintext
{"date"=>"2020-12-20", "time"=>"15:00:00", "timezone"=>"Europe/Paris"}

```

I just think I didn’t have all the cases of quotes handled before. Did you try with the second commit I made?

---

<div class="post-metadata">

### Author: ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)
#### Post date: [October 21, 2020, 4:37pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/17 "2020-10-21T16:37:52Z")

</div>

> [@j.jaffeux](#):
>
> Did you try with the second commit I made?

yep…

 ![](https://media.tenor.com/videos/62131b6fb9e521fdbdd9593792fd8ebc/mp4)

But as the raw is not

```plaintext
[date=2020-12-20 time=15:00:00 timezone=«Europe/Paris»]

```

but already

```plaintext
[date=2020-12-20 time=15:00:00 timezone="Europe/Paris"]

```

I think something is going on “further down the line” 🤔 , I actually don’t know where . `\&laquo;` and `\&raquo;` are introduced.  
Ah yes ! I can see it in the composer preview  
`[date=2020-12-15 time=14:00:00 timezone="Europe/Paris"`  
gives  
`[date=2020-12-15 time=14:00:00 timezone=« Europe/Paris »`

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [October 21, 2020, 5:01pm UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/18 "2020-10-21T17:01:20Z")

</div>

Yes maybe there are two issues front and back, because the previous fix improved deutsch case for sure, I think I can just apply the same regex frontend, I wish I could repro this 😅

Will do it tomorrow.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [December 2, 2020, 10:51am UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/21 "2020-12-02T10:51:46Z")

</div>

@Benjamin_D / @j.jaffeux is it still an issue?

---

<div class="post-metadata">

### Author: ![Benjamin\_D](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benjamin_d/32/277831_2.png) [@Benjamin\_D](https://meta.discourse.org/u/Benjamin_D)
#### Post date: [December 2, 2020, 11:50am UTC](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520/22 "2020-12-02T11:50:37Z")

</div>

I think so, but I’m lagging a bit, I’m still at 2.6.0 beta5 😳 I haven’t seen any commit about that issue since October though.

[Next page](https://meta.discourse.org/t/wrong-time-when-using-the-date-picker-bug/167520.md?page=2)
