Skip to content

Commit

Permalink
Merge pull request #113 from AlexaCRM/updateAfterRelease274
Browse files Browse the repository at this point in the history
add updates after the release
  • Loading branch information
georged authored Feb 17, 2025
2 parents 3b49b49 + 0961f35 commit 556d7dc
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
50 changes: 49 additions & 1 deletion datapress/using-twig/separate_columns_in_twig.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,54 @@ You can even define your own pattern using format_datetime() [See details](https
{{ record.birthdate|format_datetime(pattern="hh 'oclock' a, zzzz") }}
```

### How to calculate real GMT offset

To calculate the real GMT offset, you can use the following Twig syntax:

```twig
{{ "2024-08-11T17:39:00+03" | timezone_offset("Australia/Sydney") }}
```

The output: **+10:00**

```twig
{{ "2025-01-11T17:39:00+03" | timezone_offset("Australia/Sydney") }}
```

The output: **+11:00**

You can also use [Windows timezones](https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/default-time-zones?view=windows-11).

```twig
{{ "2025-01-11T17:39:00+03"|timezone_offset("Afghanistan Standard Time") }}
```
The output: **+4:30**

```twig
{{ "2025-01-11T17:39:00+03"|timezone_offset("Central America Standard Time") }}
```
The output: **-06:00**

### How to Convert Date and Time to UTC or Necessary Time Zone

Use the `convert_from_utc()` filter to convert date and time from UTC to the necessary time zone:

```twig
{{ "2025-01-11T17:39:00+03"|convert_from_utc("Australia/Sydney") }}
```

Use the `convert_to_utc()` filter to convert date and time from a specific time zone to UTC:

```twig
{{ "2025-01-11T17:39:00+03"|convert_to_utc("Australia/Sydney") }}
```

Use the `convert_timezone()` to convert date and time from UTC to Central European Standard Time in the following example:

```twig
{{ "2025-01-11T17:39:00+03"|convert_timezone("UTC","Central Europe Standard Time") }}
```

### Get lookup value

You can follow the examples below:
Expand Down Expand Up @@ -110,4 +158,4 @@ The format of displaying decimal and float columns depends on the settings of yo
{{ record.cr1d1_decimal }}
```

An example output: **50,002.25**.
An example output: **50,002.25**.
9 changes: 8 additions & 1 deletion datapress/using-twig/twig_introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ The following object members are available:
- `reference` -- *(EntityReference)* reference to the bound record.
- `record` -- *(Entity)* bound record object.
- `wp_user` -- *(WP_User)* information about the current WordPress user.
- `timezone`-- Returns the timezone for the current user. The timezone should not be null and typically returns as a string. Example output: **America/New_York**, **UTC**. The format "Asia/Tokyo" is known as an [**IANA time zone name**](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). The exact format depends on how the timezone is stored and managed in your WordPress setup. If you need to convert or manipulate this value further, you can use additional Twig filters or functions as needed.
- `timezone`-- Returns the timezone for the current user. The timezone should not be null and typically returns as a string. Example output: **America/New_York**, **UTC**. The format "Asia/Tokyo" is known as an [**IANA time zone name**](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). The exact format depends on how the timezone is stored and managed in your WordPress setup. If you need to convert or manipulate this value further, you can use additional Twig filters or functions as needed. If user timezone is not specified, it returns the actual site zone.
- `locale` -- Return locale for the current user. Example output: **en_GB**

Notice that `user.record` is more expensive performance-wise -- it retrieves data from Dataverse. `user.reference` only
Expand Down Expand Up @@ -145,6 +145,13 @@ Use the `entities` object to access any record in your Dataverse instance by its
{% endfor %}
```

### Get site timezone and locale

Use the `site` object to get the site's locale or timezone:

- `timezone`-- Returns the timezone for the site. The format "Asia/Tokyo" is known as an [**IANA time zone name**](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). The exact format depends on how the timezone is stored and managed in your WordPress setup (**Settings** -> **General**).
- `locale` -- Returns the locale for the site.

### Get current timestamp

`now` contains the value of PHP function [`time()`](https://www.php.net/manual/en/function.time.php) at the moment of Twig environment initialization.
Expand Down

0 comments on commit 556d7dc

Please sign in to comment.