fix: parse date strings as UTC
For posts, comments, and other objects, the `published` attribute is a string containing an ISO 8601 timestamp. This timestamp is UTC, though it is not explicit in the string's contents. When the `Date` constructor is used on such strings, they are parsed as though they are local timestamps. According to [1]: > When the time zone offset is absent, date-only forms are > interpreted as a UTC time and date-time forms are interpreted as local > time. This is due to a historical spec error that was not consistent > with ISO 8601 but could not be changed due to web > compatibility. This patch explicitly appends a 'Z' to the `published` string when it is used as the argument to the `Date` constructor. [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
This commit is contained in:
1 parent
035cdc23ed
commit
34c712c01c
7 files changed
+7
-7
No files matched your search
@@ -101,7 +101,7 @@
|
||||
{node.comment_view.counts.score}
|
||||
</div>
|
||||
{/if}
|
||||
<RelativeDate date={new Date(node.comment_view.comment.published)} />
|
||||
<RelativeDate date={new Date(node.comment_view.comment.published + 'Z')} />
|
||||
<span>•</span>
|
||||
<span>
|
||||
{Math.floor(
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
deleted={false}
|
||||
featured={false}
|
||||
nsfw={comment.post.nsfw}
|
||||
published={new Date(comment.post.published)}
|
||||
published={new Date(comment.post.published + 'Z')}
|
||||
saved={false}
|
||||
/>
|
||||
<Button
|
||||
|
||||
Reference in new issue
Block a user