
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@rocketseat/adonis-timezone
Advanced tools
This library provides an easy way to start using timezones with AdonisJS.
This library provides an easy way to start using timezones with AdonisJS.
adonis install @rocketseat/adonis-timezone
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();
}
}
FAQs
This library provides an easy way to start using timezones with AdonisJS.
The npm package @rocketseat/adonis-timezone receives a total of 134 weekly downloads. As such, @rocketseat/adonis-timezone popularity was classified as not popular.
We found that @rocketseat/adonis-timezone demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.