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

@shopify/dates

Package Overview
Dependencies
Maintainers
12
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/dates - npm Package Compare versions

Comparing version 0.1.8 to 0.1.9

dist/is-future-date.d.ts

2

dist/index.d.ts
export * from './apply-time-zone-offset';
export * from './get-date-time-parts';
export * from './get-time-zone-offset';
export * from './is-future-date';
export * from './is-same-day';

@@ -11,4 +12,5 @@ export * from './is-same-month';

export * from './parse-date-string';
export * from './parse-date-string-parts';
export * from './sanitise-date-string';
export * from './unapply-time-zone-offset';
export * from './map-deprecated-timezones';

@@ -7,2 +7,3 @@ "use strict";

tslib_1.__exportStar(require("./get-time-zone-offset"), exports);
tslib_1.__exportStar(require("./is-future-date"), exports);
tslib_1.__exportStar(require("./is-same-day"), exports);

@@ -15,4 +16,5 @@ tslib_1.__exportStar(require("./is-same-month"), exports);

tslib_1.__exportStar(require("./parse-date-string"), exports);
tslib_1.__exportStar(require("./parse-date-string-parts"), exports);
tslib_1.__exportStar(require("./sanitise-date-string"), exports);
tslib_1.__exportStar(require("./unapply-time-zone-offset"), exports);
tslib_1.__exportStar(require("./map-deprecated-timezones"), exports);

20

dist/parse-date-string.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var apply_time_zone_offset_1 = require("./apply-time-zone-offset");
/**
* Allowed date string formats
* yyyy-mm-dd
* yyyy-mm-ddThh:mm:ss
* yyyy-mm-ddThh:mm:ss+hh:mm
* yyyy-mm-ddThh:mm:ss-hh:mm
* yyyy-mm-ddThh:mm:ssZ
*/
var DATE_TIME_PARTS_REGEX = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2}):(\d{2})(?:(Z|(?:(\+|-)(\d{2}):(\d{2}))))?)?$/;
var parse_date_string_parts_1 = require("./parse-date-string-parts");
function parseDateString(dateString, timeZone) {
var dateTimeParts = new RegExp(DATE_TIME_PARTS_REGEX).exec(dateString);
var dateTimeParts = parse_date_string_parts_1.parseDateStringParts(dateString);
if (dateTimeParts == null) {
return null;
}
var _a = tslib_1.__read(dateTimeParts, 11),
// @ts-ignore
_ = _a[0], rawYear = _a[1], rawMonth = _a[2], rawDay = _a[3], rawHour = _a[4], rawMinute = _a[5], rawSecond = _a[6], timeZoneOffset = _a[7], sign = _a[8], rawTimeZoneHour = _a[9], rawTimeZoneMinute = _a[10];
var rawYear = dateTimeParts.year, rawMonth = dateTimeParts.month, rawDay = dateTimeParts.day, rawHour = dateTimeParts.hour, rawMinute = dateTimeParts.minute, rawSecond = dateTimeParts.second, rawMillisecond = dateTimeParts.millisecond, timeZoneOffset = dateTimeParts.timeZoneOffset, sign = dateTimeParts.sign, rawTimeZoneHour = dateTimeParts.timeZoneHour, rawTimeZoneMinute = dateTimeParts.timeZoneMinute;
var year = parseInt(rawYear, 10);

@@ -28,5 +17,6 @@ var month = parseInt(rawMonth, 10);

var second = rawSecond == null ? 0 : parseInt(rawSecond, 10);
var millisecond = rawMillisecond == null ? 0 : parseInt(rawMillisecond, 10);
var timeZoneHour = rawTimeZoneHour == null ? 0 : parseInt(rawTimeZoneHour, 10);
var timeZoneMinute = rawTimeZoneMinute == null ? 0 : parseInt(rawTimeZoneMinute, 10);
var utcDate = new Date(Date.UTC(year, month - 1, day, hour, minute, second));
var utcDate = new Date(Date.UTC(year, month - 1, day, hour, minute, second, millisecond));
if (timeZoneOffset === 'Z') {

@@ -33,0 +23,0 @@ return utcDate;

{
"name": "@shopify/dates",
"version": "0.1.8",
"version": "0.1.9",
"license": "MIT",

@@ -30,3 +30,3 @@ "description": "Lightweight date operations library.",

"devDependencies": {
"@shopify/jest-dom-mocks": "^2.2.0",
"@shopify/jest-dom-mocks": "^2.2.1",
"typescript": "~3.0.1"

@@ -33,0 +33,0 @@ },

@@ -68,2 +68,15 @@ # `@shopify/dates`

### `isFutureDate`
Takes in a date object and an optional now date object to compare against (defaulting to a new date object). Returns a boolean indicating whether or not the first date is in the future.
```ts
import {isFutureDate} from '@shopify/dates';
const now = new Date('2018-01-01Z00:00');
const date = new Date('2018-01-02Z23:59');
const futureDay = isFutureDate(date, now);
```
### `isSameDay`

@@ -174,2 +187,26 @@

### `parseDateStringParts`
Takes in a date string. Returns parsed parts from that date string.
```ts
import {parseDateStringParts} from '@shopify/dates';
const date = '2018-05-28T12:30:00.123+05:30';
const {
year,
month,
day,
hour,
minute,
second,
millisecond,
timeZoneOffset,
sign,
timeZoneHour,
timeZoneMinute,
} = parseDateStringParts(date);
```
### `unapplyTimeZoneOffset`

@@ -176,0 +213,0 @@

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