New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

datetime-offset

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datetime-offset - npm Package Compare versions

Comparing version 0.2.0-beta to 0.3.0-beta

10

DateTimeOffset.js

@@ -30,3 +30,3 @@ 'use strict';

}
toString(format = defaultFormat, timezone = 'GMT') {
toString(timezone = 'GMT', format = defaultFormat) {
if (!_timezoneConsts2.default[timezone]) throw new Error(_errorConsts2.default.UNSUPPORTED_TZ);

@@ -75,3 +75,9 @@ return this.datetime.tz(_timezoneConsts2.default[timezone]).format(format);

compareTo(datetimeOffset) {
throw new Error('compareTo undefined');
if (arguments.length < 1) throw new Error(_errorConsts2.default.REQUIRE_MORE_ARG);
if (arguments.length > 1) throw new Error(_errorConsts2.default.TOO_MANY_ARG);
if (!(datetimeOffset instanceof DateTimeOffset)) {
throw new Error(_errorConsts2.default.REQUIRE_DATETIMEOFFSET_ARG);
}
const result = this.datetime - datetimeOffset.datetime;
return result;
}

@@ -78,0 +84,0 @@ equals(datetimeOffset) {

6

error-consts.js

@@ -5,7 +5,9 @@ 'use strict';

const message = {
UNSUPPORTED_TZ: 'Unsupported Timzone',
UNSUPPORTED_TZ: 'Unsupported Timezone',
REQUIRE_NUMBER_ARG: 'Require Argument typeof Number',
REQUIRE_MORE_ARG: 'Require More Argument'
REQUIRE_DATETIMEOFFSET_ARG: 'Require Argument instanceof DateTimeOffset',
REQUIRE_MORE_ARG: 'Require More Arguments',
TOO_MANY_ARG: 'Too Many Arguments'
};
exports.default = message;
{
"name": "datetime-offset",
"version": "0.2.0-beta",
"version": "0.3.0-beta",
"description": "Javascript Class like C# DateTimeOffset Structure (mapping momnet-timezome)",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -44,2 +44,3 @@ # datetime-offset.js

### `toString(format = 'YYYY-MM-DD HH:mm:ss', timezone = 'GMT')`
- **The order of the `format` and `timezone` parameters has changed since version 0.3.0.**
- Default `format` : YYYY-MM-DD HH:mm:ss

@@ -52,5 +53,6 @@ - Default `timezone` : GMT

t2.toString() // 2017-04-10 00:00:00
t2.toString(undefined, 'UTC') // 2017-04-10 00:00:00
t2.toString(undefined, 'KST') // 2017-04-10 09:00:00
t2.toString('YYYY-MM-DD') // 2017-04-10
t2.toString('UTC') // 2017-04-10 00:00:00
t2.toString('KST') // 2017-04-10 09:00:00
t2.toString('UTC', 'YYYY-MM-DD') // 2017-04-10
t2.toString(undefined, 'YYYY-MM-DD') // 2017-04-10 timezone default set 'UTC'

@@ -63,5 +65,6 @@ const t4 = new DateTimeOffset('2017-04-10 09:00:00', {

t4.toString() // 2017-04-10 00:00:00
t4.toString(undefined, 'UTC') // 2017-04-10 00:00:00
t4.toString(undefined, 'KST') // 2017-04-10 09:00:00
t4.toString('YYYY-MM-DD') // 2017-04-10
t4.toString('UTC') // 2017-04-10 00:00:00
t4.toString('KST') // 2017-04-10 09:00:00
t4.toString('UTC', 'YYYY-MM-DD') // 2017-04-10
t4.toString(undefined, 'YYYY-MM-DD') // 2017-04-10 timezone default set 'UTC'
```

@@ -140,12 +143,31 @@

### `static compare(DateTimeOffset, DateTimeOffset)`
- To be developed
### `compareTo(DateTimeOffset)`
- To be developed
- Compares to DateTimeOffset and returns the subtracted value
```javascript
const customTime = '2017-04-10T00:00:00Z';
const customTime2 = '2017-04-09T23:50:00Z';
const customTime3 = '2017-04-10T00:10:00Z';
const t = new DateTimeOffset(customTime);
const t2 = new DateTimeOffset(customTime2);
const t3 = new DateTimeOffset(customTime3);
console.log(t.compareTo(t)); // 0
console.log(t.compareTo(t2)); // 600000
console.log(t.compareTo(t3)); // -600000
t.compareTo(); // throw Error
t.compareTo(t2, t3); // throw Error
t.compareTo(new Date()); // throw Error
t.compareTo('https://fb.com/luckyyowu'); // throw Error
```
### `equals(DateTimeOffset)`
- To be developed
### `static compare(DateTimeOffset, DateTimeOffset)`
- To be developed
p
### `static equals(DateTimeOffset, DateTimeOffset)`
- To be developed
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