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

djz

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djz - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

index.d.ts

@@ -1,2 +0,2 @@

import Dateo from './dateo.mjs'
import Dateo from './dateo'
export {Dateo}
{
"name": "djz",
"version": "0.0.2",
"version": "0.0.3",
"description": "Timezone-aware better Javascript Date",
"main": "index.cjs",
"type": "module",
"exports": {

@@ -7,0 +8,0 @@ ".": {

@@ -24,2 +24,45 @@ # djz - Timezone-aware better Javascript Date

### Wallclock methods
For all below methods, `wallclock` is one of: `fullYear`, `month`, `date`, `hours`, `minutes`, `seconds`, `milliseconds`.
These methods manipulate the wallclock time with respect to a particular timezone, regardless of the timezone of the runtime.
- `get wallclock`: `wallclock = date.wallclock`.
- `set wallclock`: `date.wallclock = wallclock`. The value can be the new value, or a function that takes the old value and returns the new value or undefined to skip setting.
For example: `date.setFullYear(year => year + 1)`, `date.setFullYear(2020)`, `date.setFullYear()`, `date.setFullYear(() => undefined)`.
- `getWallclock()`
- `setWallclock()`: set the wallclock and return the Dateo instance. Example: `date.setMonth(x => x + 1).setDate(1) === date`.
- `withWallclock()`: return a new Dateo instance with the wallclock set. Example: `date.withWallclock({month: 1, date: 1}) !== date`.
Besides, `day` wallclock is get only.
- `get day`.
- `getDay()`.
### Timezone
TimezoneOffset methods return the timezone offset in minutes with reverse sign.
These methods for compatibility with Date.
For example: GMT+9 returns -540.
- `get timezoneOffset`: always return the pre-defined timezone offset, not the runtime timezone offset.
- `set timezoneOffset`: change the timezone offset, but keep the value of `getTime()` (epoch) unchanged. The value can be the new value, or a function that takes the old value and returns the new value or undefined to skip setting.
- `getTimezoneOffset()`.
- `setTimezoneOffset()`: set the timezone offset and return the Dateo instance.
- `withTimezoneOffset()`: return a new Dateo instance with the timezone offset set.
Timezone (no `Offset` suffix) methods return the timezone offset in hour with correct sign.
For example: GMT+9 returns 9.
- `get timezone`: always return the pre-defined timezone offset, not the runtime timezone offset.
- `set timezone`: change the timezone offset, but keep the value of `getTime()` (epoch) unchanged. The value can be the new value, or a function that takes the old value and returns the new value or undefined to skip setting.
- `getTimezone()`.
- `setTimezone()`: set the timezone offset and return the Dateo instance.
- `withTimezone()`: return a new Dateo instance with the timezone offset set.
### Epoch methods
- `get time`: return the epoch time.
- `set time`: set the epoch time. The value can be the new value, or a function that takes the old value and returns the new value or undefined to skip setting.
- `getTime()`.
- `setTime()`: set the epoch time and return the Dateo instance.
- `withTime()`: return a new Dateo instance with the epoch time set.
### Constructor

@@ -83,46 +126,4 @@ All constructors support the last optional `options` argument. The `options` is an object with the following properties:

### Wallclock methods
For all below methods, `wallclock` is one of: `fullYear`, `month`, `date`, `hours`, `minutes`, `seconds`, `milliseconds`.
These methods manipulate the wallclock time with respect to a particular timezone, regardless of the timezone of the runtime.
- `get wallclock`: `wallclock = date.wallclock`.
- `set wallclock`: `date.wallclock = wallclock`. The value can be the new value, or a function that takes the old value and returns the new value or undefined to skip setting.
For example: `date.setFullYear(year => year + 1)`, `date.setFullYear(2020)`, `date.setFullYear()`, `date.setFullYear(() => undefined)`.
- `getWallclock()`
- `setWallclock()`: set the wallclock and return the Dateo instance. Example: `date.setMonth(x => x + 1).setDate(1) === date`.
- `withWallclock()`: return a new Dateo instance with the wallclock set. Example: `date.withWallclock({month: 1, date: 1}) !== date`.
Besides, `day` wallclock is get only.
- `get day`.
- `getDay()`.
### Timezone
TimezoneOffset methods return the timezone offset in minutes with reverse sign.
These methods for compatibility with Date.
For example: GMT+9 returns -540.
- `get timezoneOffset`: always return the pre-defined timezone offset, not the runtime timezone offset.
- `set timezoneOffset`: change the timezone offset, but keep the value of `getTime()` (epoch) unchanged. The value can be the new value, or a function that takes the old value and returns the new value or undefined to skip setting.
- `getTimezoneOffset()`.
- `setTimezoneOffset()`: set the timezone offset and return the Dateo instance.
- `withTimezoneOffset()`: return a new Dateo instance with the timezone offset set.
Timezone (no `Offset` suffix) methods return the timezone offset in hour with correct sign.
For example: GMT+9 returns 9.
- `get timezone`: always return the pre-defined timezone offset, not the runtime timezone offset.
- `set timezone`: change the timezone offset, but keep the value of `getTime()` (epoch) unchanged. The value can be the new value, or a function that takes the old value and returns the new value or undefined to skip setting.
- `getTimezone()`.
- `setTimezone()`: set the timezone offset and return the Dateo instance.
- `withTimezone()`: return a new Dateo instance with the timezone offset set.
### Epoch methods
- `get time`: return the epoch time.
- `set time`: set the epoch time. The value can be the new value, or a function that takes the old value and returns the new value or undefined to skip setting.
- `getTime()`.
- `setTime()`: set the epoch time and return the Dateo instance.
- `withTime()`: return a new Dateo instance with the epoch time set.
## TODO
- [ ] Implement `Datez` class, with timezone defined by name. For example: `'Asia/Tokyo'`. Which might require `Intl` available in the runtime.
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