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

@wordpress/date

Package Overview
Dependencies
Maintainers
8
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/date - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

src/test/index.js

34

build-module/index.js

@@ -130,2 +130,8 @@ /**

export var moment = function moment() {
deprecated('wp.date.moment', {
version: '4.4',
alternative: 'the moment script as a dependency',
plugin: 'Gutenberg'
});
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {

@@ -405,3 +411,31 @@ args[_key] = arguments[_key];

}
/**
* Check whether a date is considered in the future according to the WordPress settings.
*
* @param {string} dateValue Date String or Date object in the Defined WP Timezone.
*
* @return {boolean} Is in the future.
*/
export function isInTheFuture(dateValue) {
var now = momentLib.tz('WP');
var momentObject = momentLib.tz(dateValue, 'WP');
return momentObject.isAfter(now);
}
/**
* Create and return a JavaScript Date Object from a date string in the WP timezone.
*
* @param {string?} dateString Date formatted in the WP timezone.
*
* @return {Date} Date
*/
export function getDate(dateString) {
if (!dateString) {
return momentLib.tz('WP').toDate();
}
return momentLib.tz(dateString, 'WP').toDate();
}
setupWPTimezone();
//# sourceMappingURL=index.js.map

@@ -15,2 +15,4 @@ "use strict";

exports.dateI18n = dateI18n;
exports.isInTheFuture = isInTheFuture;
exports.getDate = getDate;
exports.moment = void 0;

@@ -156,2 +158,8 @@

var moment = function moment() {
(0, _deprecated.default)('wp.date.moment', {
version: '4.4',
alternative: 'the moment script as a dependency',
plugin: 'Gutenberg'
});
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {

@@ -436,4 +444,36 @@ args[_key] = arguments[_key];

}
/**
* Check whether a date is considered in the future according to the WordPress settings.
*
* @param {string} dateValue Date String or Date object in the Defined WP Timezone.
*
* @return {boolean} Is in the future.
*/
function isInTheFuture(dateValue) {
var now = _moment.default.tz('WP');
var momentObject = _moment.default.tz(dateValue, 'WP');
return momentObject.isAfter(now);
}
/**
* Create and return a JavaScript Date Object from a date string in the WP timezone.
*
* @param {string?} dateString Date formatted in the WP timezone.
*
* @return {Date} Date
*/
function getDate(dateString) {
if (!dateString) {
return _moment.default.tz('WP').toDate();
}
return _moment.default.tz(dateString, 'WP').toDate();
}
setupWPTimezone();
//# sourceMappingURL=index.js.map

8

CHANGELOG.md

@@ -0,1 +1,7 @@

## 2.2.0 (2018-11-09)
### Deprecations
- Remove `moment` from the public API for the date module.
## 2.1.0 (2018-10-29)

@@ -5,3 +11,3 @@

- Marked getSettings as experimental
- Marked getSettings as experimental

@@ -8,0 +14,0 @@ ## 2.0.3 (2018-09-26)

6

package.json
{
"name": "@wordpress/date",
"version": "2.1.0",
"version": "2.2.0",
"description": "Date module for WordPress.",

@@ -21,2 +21,3 @@ "author": "The WordPress Contributors",

"module": "build-module/index.js",
"react-native": "src/index",
"dependencies": {

@@ -29,4 +30,3 @@ "@babel/runtime": "^7.0.0",

"access": "public"
},
"gitHead": "308f6aa950705531ef9d360dc88bb9f4194542f5"
}
}

@@ -122,2 +122,8 @@ /**

export const moment = ( ...args ) => {
deprecated( 'wp.date.moment', {
version: '4.4',
alternative: 'the moment script as a dependency',
plugin: 'Gutenberg',
} );
return momentLib.tz( ...args, 'WP' );

@@ -390,2 +396,31 @@ };

/**
* Check whether a date is considered in the future according to the WordPress settings.
*
* @param {string} dateValue Date String or Date object in the Defined WP Timezone.
*
* @return {boolean} Is in the future.
*/
export function isInTheFuture( dateValue ) {
const now = momentLib.tz( 'WP' );
const momentObject = momentLib.tz( dateValue, 'WP' );
return momentObject.isAfter( now );
}
/**
* Create and return a JavaScript Date Object from a date string in the WP timezone.
*
* @param {string?} dateString Date formatted in the WP timezone.
*
* @return {Date} Date
*/
export function getDate( dateString ) {
if ( ! dateString ) {
return momentLib.tz( 'WP' ).toDate();
}
return momentLib.tz( dateString, 'WP' ).toDate();
}
setupWPTimezone();

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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