Skip to content

Commit

Permalink
docs(helper): relative_date and time_tag
Browse files Browse the repository at this point in the history
  • Loading branch information
D-Sketon committed Jan 22, 2024
1 parent 426131f commit c5d9085
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 0 deletions.
36 changes: 36 additions & 0 deletions source/docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,42 @@ Inserts formatted date and time. `date` can be unix time, ISO string, date objec
// Tuesday, January 1st 2013, 12:00:00 am
```

### relative_date

Inserts relative time from now. `date` can be unix time, ISO string, date object, or [Moment.js] object.

```js
<%- relative_date(date) %>
```

**Examples:**

``` js
<%- relative_date(new Date()) %>
// a few seconds ago

<%- relative_date(new Date(1000000000000)) %>
// 22 years ago
```

### time_tag

Inserts time tag. `date` can be unix time, ISO string, date object, or [Moment.js] object. `format` is `date_format` setting by default.

```js
<%- time_tag(date, [format]) %>
```

**Examples:**

``` js
<%- time_tag(new Date()) %>
// <time datetime="2024-01-22T06:35:31.108Z">2024-01-22</time>

<%- time_tag(new Date(), 'MMM-D-YYYY') %>
// <time datetime="2024-01-22T06:35:31.108Z">Jan-22-2024</time>
```

### moment

[Moment.js] library.
Expand Down
36 changes: 36 additions & 0 deletions source/ru/docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,42 @@ Escapes HTML entities in a string.
// Tuesday, January 1st 2013, 12:00:00 am
```

### relative_date

Inserts relative time from now. `date` can be unix time, ISO string, date object, or [Moment.js] object.

```js
<%- relative_date(date) %>
```

**Examples:**

``` js
<%- relative_date(new Date()) %>
// a few seconds ago

<%- relative_date(new Date(1000000000000)) %>
// 22 years ago
```

### time_tag

Inserts time tag. `date` can be unix time, ISO string, date object, or [Moment.js] object. `format` is `date_format` setting by default.

```js
<%- time_tag(date, [format]) %>
```

**Examples:**

``` js
<%- time_tag(new Date()) %>
// <time datetime="2024-01-22T06:35:31.108Z">2024-01-22</time>

<%- time_tag(new Date(), 'MMM-D-YYYY') %>
// <time datetime="2024-01-22T06:35:31.108Z">Jan-22-2024</time>
```

### moment

Библиотека [Moment.js](https://momentjs.com/).
Expand Down
36 changes: 36 additions & 0 deletions source/zh-cn/docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,42 @@ url: https://example.com/blog # example
// Tuesday, January 1st 2013, 12:00:00 am
```

### relative_date

插入相对当前的时间。`date` 可以是 UNIX 时间、ISO 字符串、Date 对象或 [Moment.js] 对象。

```js
<%- relative_date(date) %>
```

**示例:**

``` js
<%- relative_date(new Date()) %>
// a few seconds ago

<%- relative_date(new Date(1000000000000)) %>
// 22 years ago
```

### time_tag

插入时间标签。`date` 可以是 UNIX 时间、ISO 字符串、Date 对象或 [Moment.js] 对象。`format` 默认为 `date_format` 配置信息。

```js
<%- time_tag(date, [format]) %>
```

**示例:**

``` js
<%- time_tag(new Date()) %>
// <time datetime="2024-01-22T06:35:31.108Z">2024-01-22</time>

<%- time_tag(new Date(), 'MMM-D-YYYY') %>
// <time datetime="2024-01-22T06:35:31.108Z">Jan-22-2024</time>
```

### moment

[Moment.js] 函数库。
Expand Down
36 changes: 36 additions & 0 deletions source/zh-tw/docs/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,42 @@ Escapes HTML entities in a string.
// Tuesday, January 1st 2013, 12:00:00 am
```

### relative_date

Inserts relative time from now. `date` can be unix time, ISO string, date object, or [Moment.js] object.

```js
<%- relative_date(date) %>
```

**Examples:**

``` js
<%- relative_date(new Date()) %>
// a few seconds ago

<%- relative_date(new Date(1000000000000)) %>
// 22 years ago
```

### time_tag

Inserts time tag. `date` can be unix time, ISO string, date object, or [Moment.js] object. `format` is `date_format` setting by default.

```js
<%- time_tag(date, [format]) %>
```

**Examples:**

``` js
<%- time_tag(new Date()) %>
// <time datetime="2024-01-22T06:35:31.108Z">2024-01-22</time>

<%- time_tag(new Date(), 'MMM-D-YYYY') %>
// <time datetime="2024-01-22T06:35:31.108Z">Jan-22-2024</time>
```

### moment

[Moment.js] 函式庫。
Expand Down

0 comments on commit c5d9085

Please sign in to comment.