@wordpress/date
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -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 |
@@ -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) |
{ | ||
"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
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
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
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
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
2
1243
83800