Comparing version 0.0.2 to 0.0.3
@@ -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. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
43565
128
0
Yes