0.36.0 • Published 5 years ago
@narando/timezones v0.36.0
@narando/timezones
A custom timezone toolkit on narando architecture.
Getting Started
You need to have nodejs and npm installed.
$ npm install @narando/timezonesUsage
Get a list of all timezones to fill a <optgroup>. Or parse a UTC Time to a given timezone.
To create an instance of the timezones module you have to import timezones
import buildTimezoneList from "@narando/buildTimezoneList";
function handleRequest(req, res) {
  // You can use the function to get a grouped list of all timezones.
  // With the parameter set is the given timezone preselected.
  // This list can be used to generate an `<optgroup>`.
  res.locals.timezones = buildTimezoneList(req.user.timezone);
  res.render(`page/article`, res.locals);
}The timezones will be displayed by the following mustache logic. In this case it will display all timezones with the user timezone selected.
<select  class="form-control">
  {{#timezones}}
  <optgroup label="{{name}}">
    {{#zones}}
    <option value="{{name}}" {{#expected}} selected {{/expected}}>{{description}} </option>
    {{/zones}}
  </optgroup>
  {{/timezones}}
</select>Formatting UTC Time
To format a UTC in a given timezone use the following example.
import formatTime from "../formatTime";
const formattedReleaseTime = formatTime(releaseTime, req.user.timezone);0.36.0
5 years ago
0.35.0
5 years ago
0.34.1
5 years ago
0.34.0
5 years ago
0.33.0
5 years ago
0.32.0
5 years ago
0.31.0
5 years ago
0.30.0
6 years ago
0.29.0
6 years ago
0.28.5
6 years ago
0.28.4
6 years ago
0.28.0
6 years ago
0.27.0
6 years ago
0.26.1
6 years ago
0.25.0
7 years ago
0.24.0
7 years ago
0.22.1
7 years ago
0.22.0
7 years ago
0.21.1
7 years ago
0.12.0
7 years ago