Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rocketseat/adonis-timezone

Package Overview
Dependencies
Maintainers
7
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rocketseat/adonis-timezone

This library provides an easy way to start using timezones with AdonisJS.

  • 0.7.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
7
Created
Source

Adonis Timezone Provider

This library provides an easy way to start using timezones with AdonisJS.

Coverage Status

Install

adonis install @rocketseat/adonis-timezone

Use

To use this provider you need to add a trait inside your Model, like this:

class User extends Model {
  static boot() {
    super.boot();

    this.addTrait("@provider:Timezone/Trait");
  }
}
OBS: Unfortunately cannot overwrite castDates

And you need to create a middleware and inside it, use the timezone context variable.

On the timezone variable, you can choose the timezone, that your model will provide the timestamps and custom time & date.

class Timezone {
  async handle({ timezone }, next) {
    timezone.activate("America/Sao_Paulo");
    await next();
  }
}

If you'd like to add user's timezone, then you should add a named middleware to the timezone and the user must have a timezone field in their Model.

class Timezone {
  async handle({ timezone, auth }, next) {
    timezone.activate(auth.user.timezone);
    await next();
  }
}

Keywords

FAQs

Package last updated on 17 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc