add formatting of meta.created with Date object

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2018-12-13 00:36:43 +01:00
parent f2218da7ab
commit 76e9e727ee
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
2 changed files with 7 additions and 4 deletions

View File

@ -9,10 +9,13 @@ class Comments {
constructor(client, owner, repo, builds) {
this.gh = client
this.db = builds
this.nj = nunjucks.configure()
this.template = template
this.repo = repo /* name of repo to query */
this.owner = owner /* name of user who makes the comments */
/* setup templating for comments */
this.template = template
this.nj = new nunjucks.Environment()
/* add helper for formatting dates */
this.nj.addFilter('date', (data) => (new Date(data)).toLocaleTimeString('utc'))
}
async listComments (pr, per_page = PER_PAGE, sort = 'updated', direction = 'desc') {

View File

@ -4,9 +4,9 @@ module.exports = `
|-|-|-|-|-|-|-|
{% for b in builds -%}
{%- if b.success -%}
| :heavy_check_mark: | {{ b.commit }} | {{ b.meta.created }} | \`{{ b.platform }}\` | [{{ b.pr }}#{{ b.id }}]({{ b.url }}) | {{ b.duration }} | [:package: {{ b.platform }}]({{ b.pkg_url }}) |
| :heavy_check_mark: | {{ b.commit }} | {{ b.meta.created | date }} | \`{{ b.platform }}\` | [#{{ b.id }}]({{ b.url }}) | {{ b.duration }} | [:package: {{ b.platform }}]({{ b.pkg_url }}) |
{% else -%}
| :x: | {{ b.commit }} | {{ b.meta.created }} | \`{{ b.platform }}\` | [{{ b.pr }}#{{ b.id }}]({{ b.url }}) | {{ b.duration }} | [:page_facing_up: build log]({{ b.pkg_url }}consoleText) |
| :x: | {{ b.commit }} | {{ b.meta.created | date }} | \`{{ b.platform }}\` | [#{{ b.id }}]({{ b.url }}) | {{ b.duration }} | [:page_facing_up: build log]({{ b.pkg_url }}consoleText) |
{% endif -%}
{%- endfor -%}
`