Skip to content

Commit 65b89e2

Browse files
ellatrixdmsnell
authored andcommitted
Restore: Sync Gutenberg @ f4d8a5803aa2fbe26e7d9af4d17e80a622b7bab8
See changelog in 8a7d2ce > Gutenberg ref update. > Only includes the following commit: WordPress/gutenberg@f4d8a58. > > "DataForm datetime control: fix date handling" (WordPress/gutenberg#76193)
1 parent 7da597a commit 65b89e2

16 files changed

Lines changed: 69 additions & 109 deletions

File tree

src/wp-includes/assets/script-loader-packages.min.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
'wp-url',
101101
'wp-warning'
102102
),
103-
'version' => '7d8ba03c46a31976363c'
103+
'version' => 'ca7e8cfd2cd06d8897bb'
104104
),
105105
'block-library.min.js' => array(
106106
'dependencies' => array(
@@ -424,7 +424,7 @@
424424
'import' => 'static'
425425
)
426426
),
427-
'version' => 'b73b3bc48dddd6b78b65'
427+
'version' => '9f119c2d05657de42da1'
428428
),
429429
'edit-widgets.min.js' => array(
430430
'dependencies' => array(
@@ -511,7 +511,7 @@
511511
'import' => 'static'
512512
)
513513
),
514-
'version' => 'f6b5f35286ac82ea0bc7'
514+
'version' => 'e157f65c34ea74a71709'
515515
),
516516
'element.min.js' => array(
517517
'dependencies' => array(
@@ -626,7 +626,7 @@
626626
'wp-url',
627627
'wp-warning'
628628
),
629-
'version' => '68f7334c7a77bb83ffee'
629+
'version' => '490d1513362c0dd0d184'
630630
),
631631
'notices.min.js' => array(
632632
'dependencies' => array(

src/wp-includes/build/routes/navigation-list/content.js

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13832,14 +13832,11 @@ function parseDateTime(dateTimeString) {
1383213832
// packages/dataviews/build-module/components/dataform-controls/datetime.mjs
1383313833
var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
1383413834
var { DateCalendar, ValidatedInputControl } = unlock(import_components33.privateApis);
13835-
var formatDateTime = (date) => {
13836-
if (!date) {
13835+
var formatDateTime = (value) => {
13836+
if (!value) {
1383713837
return "";
1383813838
}
13839-
if (typeof date === "string") {
13840-
return date;
13841-
}
13842-
return format(date, "yyyy-MM-dd'T'HH:mm");
13839+
return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
1384313840
};
1384413841
function CalendarDateTimeControl({
1384513842
data,
@@ -13874,17 +13871,14 @@ function CalendarDateTimeControl({
1387413871
(newDate) => {
1387513872
let dateTimeValue;
1387613873
if (newDate) {
13877-
let finalDateTime = newDate;
13874+
const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
13875+
let wpTime;
1387813876
if (value) {
13879-
const currentDateTime = parseDateTime(value);
13880-
if (currentDateTime) {
13881-
finalDateTime = new Date(newDate);
13882-
finalDateTime.setHours(currentDateTime.getHours());
13883-
finalDateTime.setMinutes(
13884-
currentDateTime.getMinutes()
13885-
);
13886-
}
13877+
wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
13878+
} else {
13879+
wpTime = (0, import_date3.dateI18n)("H:i", newDate);
1388713880
}
13881+
const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
1388813882
dateTimeValue = finalDateTime.toISOString();
1388913883
onChangeCallback(dateTimeValue);
1389013884
if (validationTimeoutRef.current) {
@@ -13910,7 +13904,7 @@ function CalendarDateTimeControl({
1391013904
const handleManualDateTimeChange = (0, import_element43.useCallback)(
1391113905
(newValue) => {
1391213906
if (newValue) {
13913-
const dateTime = new Date(newValue);
13907+
const dateTime = (0, import_date3.getDate)(newValue);
1391413908
onChangeCallback(dateTime.toISOString());
1391513909
const parsedDate = parseDateTime(dateTime.toISOString());
1391613910
if (parsedDate) {
@@ -13963,9 +13957,7 @@ function CalendarDateTimeControl({
1396313957
type: "datetime-local",
1396413958
label: (0, import_i18n33.__)("Date time"),
1396513959
hideLabelFromVision: true,
13966-
value: value ? formatDateTime(
13967-
parseDateTime(value) || void 0
13968-
) : "",
13960+
value: formatDateTime(value),
1396913961
onChange: handleManualDateTimeChange
1397013962
}
1397113963
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-private-apis', 'wp-theme', 'wp-warning'), 'module_dependencies' => array(array('id' => '@wordpress/a11y', 'import' => 'static'), array('id' => '@wordpress/route', 'import' => 'static')), 'version' => 'a0c85e40286c555c8ac2');
1+
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-notices', 'wp-preferences', 'wp-primitives', 'wp-private-apis', 'wp-theme', 'wp-warning'), 'module_dependencies' => array(array('id' => '@wordpress/a11y', 'import' => 'static'), array('id' => '@wordpress/route', 'import' => 'static')), 'version' => 'a885dc9fca8de5745946');

src/wp-includes/build/routes/navigation-list/content.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/wp-includes/build/routes/pattern-list/content.js

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13743,14 +13743,11 @@ function parseDateTime(dateTimeString) {
1374313743
// packages/dataviews/build-module/components/dataform-controls/datetime.mjs
1374413744
var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
1374513745
var { DateCalendar, ValidatedInputControl } = unlock(import_components31.privateApis);
13746-
var formatDateTime = (date) => {
13747-
if (!date) {
13746+
var formatDateTime = (value) => {
13747+
if (!value) {
1374813748
return "";
1374913749
}
13750-
if (typeof date === "string") {
13751-
return date;
13752-
}
13753-
return format(date, "yyyy-MM-dd'T'HH:mm");
13750+
return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
1375413751
};
1375513752
function CalendarDateTimeControl({
1375613753
data,
@@ -13785,17 +13782,14 @@ function CalendarDateTimeControl({
1378513782
(newDate) => {
1378613783
let dateTimeValue;
1378713784
if (newDate) {
13788-
let finalDateTime = newDate;
13785+
const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
13786+
let wpTime;
1378913787
if (value) {
13790-
const currentDateTime = parseDateTime(value);
13791-
if (currentDateTime) {
13792-
finalDateTime = new Date(newDate);
13793-
finalDateTime.setHours(currentDateTime.getHours());
13794-
finalDateTime.setMinutes(
13795-
currentDateTime.getMinutes()
13796-
);
13797-
}
13788+
wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
13789+
} else {
13790+
wpTime = (0, import_date3.dateI18n)("H:i", newDate);
1379813791
}
13792+
const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
1379913793
dateTimeValue = finalDateTime.toISOString();
1380013794
onChangeCallback(dateTimeValue);
1380113795
if (validationTimeoutRef.current) {
@@ -13821,7 +13815,7 @@ function CalendarDateTimeControl({
1382113815
const handleManualDateTimeChange = (0, import_element42.useCallback)(
1382213816
(newValue) => {
1382313817
if (newValue) {
13824-
const dateTime = new Date(newValue);
13818+
const dateTime = (0, import_date3.getDate)(newValue);
1382513819
onChangeCallback(dateTime.toISOString());
1382613820
const parsedDate = parseDateTime(dateTime.toISOString());
1382713821
if (parsedDate) {
@@ -13874,9 +13868,7 @@ function CalendarDateTimeControl({
1387413868
type: "datetime-local",
1387513869
label: (0, import_i18n33.__)("Date time"),
1387613870
hideLabelFromVision: true,
13877-
value: value ? formatDateTime(
13878-
parseDateTime(value) || void 0
13879-
) : "",
13871+
value: formatDateTime(value),
1388013872
onChange: handleManualDateTimeChange
1388113873
}
1388213874
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-patterns', 'wp-preferences', 'wp-primitives', 'wp-private-apis', 'wp-theme', 'wp-warning'), 'module_dependencies' => array(array('id' => '@wordpress/a11y', 'import' => 'static'), array('id' => '@wordpress/lazy-editor', 'import' => 'static'), array('id' => '@wordpress/route', 'import' => 'static')), 'version' => 'fe1e130ea4030b5bc5df');
1+
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-patterns', 'wp-preferences', 'wp-primitives', 'wp-private-apis', 'wp-theme', 'wp-warning'), 'module_dependencies' => array(array('id' => '@wordpress/a11y', 'import' => 'static'), array('id' => '@wordpress/lazy-editor', 'import' => 'static'), array('id' => '@wordpress/route', 'import' => 'static')), 'version' => 'f187a8ed84eb97f615a9');

src/wp-includes/build/routes/pattern-list/content.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/wp-includes/build/routes/post-list/content.js

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13722,14 +13722,11 @@ function parseDateTime(dateTimeString) {
1372213722
// packages/dataviews/build-module/components/dataform-controls/datetime.mjs
1372313723
var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
1372413724
var { DateCalendar, ValidatedInputControl } = unlock(import_components31.privateApis);
13725-
var formatDateTime = (date) => {
13726-
if (!date) {
13725+
var formatDateTime = (value) => {
13726+
if (!value) {
1372713727
return "";
1372813728
}
13729-
if (typeof date === "string") {
13730-
return date;
13731-
}
13732-
return format(date, "yyyy-MM-dd'T'HH:mm");
13729+
return (0, import_date3.dateI18n)("Y-m-d\\TH:i", (0, import_date3.getDate)(value));
1373313730
};
1373413731
function CalendarDateTimeControl({
1373513732
data,
@@ -13764,17 +13761,14 @@ function CalendarDateTimeControl({
1376413761
(newDate) => {
1376513762
let dateTimeValue;
1376613763
if (newDate) {
13767-
let finalDateTime = newDate;
13764+
const wpDate = (0, import_date3.dateI18n)("Y-m-d", newDate);
13765+
let wpTime;
1376813766
if (value) {
13769-
const currentDateTime = parseDateTime(value);
13770-
if (currentDateTime) {
13771-
finalDateTime = new Date(newDate);
13772-
finalDateTime.setHours(currentDateTime.getHours());
13773-
finalDateTime.setMinutes(
13774-
currentDateTime.getMinutes()
13775-
);
13776-
}
13767+
wpTime = (0, import_date3.dateI18n)("H:i", (0, import_date3.getDate)(value));
13768+
} else {
13769+
wpTime = (0, import_date3.dateI18n)("H:i", newDate);
1377713770
}
13771+
const finalDateTime = (0, import_date3.getDate)(`${wpDate}T${wpTime}`);
1377813772
dateTimeValue = finalDateTime.toISOString();
1377913773
onChangeCallback(dateTimeValue);
1378013774
if (validationTimeoutRef.current) {
@@ -13800,7 +13794,7 @@ function CalendarDateTimeControl({
1380013794
const handleManualDateTimeChange = (0, import_element42.useCallback)(
1380113795
(newValue) => {
1380213796
if (newValue) {
13803-
const dateTime = new Date(newValue);
13797+
const dateTime = (0, import_date3.getDate)(newValue);
1380413798
onChangeCallback(dateTime.toISOString());
1380513799
const parsedDate = parseDateTime(dateTime.toISOString());
1380613800
if (parsedDate) {
@@ -13853,9 +13847,7 @@ function CalendarDateTimeControl({
1385313847
type: "datetime-local",
1385413848
label: (0, import_i18n33.__)("Date time"),
1385513849
hideLabelFromVision: true,
13856-
value: value ? formatDateTime(
13857-
parseDateTime(value) || void 0
13858-
) : "",
13850+
value: formatDateTime(value),
1385913851
onChange: handleManualDateTimeChange
1386013852
}
1386113853
)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-preferences', 'wp-primitives', 'wp-private-apis', 'wp-theme', 'wp-warning'), 'module_dependencies' => array(array('id' => '@wordpress/a11y', 'import' => 'static'), array('id' => '@wordpress/route', 'import' => 'static')), 'version' => 'ed085b811a3dfd39d1b1');
1+
<?php return array('dependencies' => array('react', 'react-dom', 'react-jsx-runtime', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-date', 'wp-deprecated', 'wp-editor', 'wp-element', 'wp-i18n', 'wp-keycodes', 'wp-preferences', 'wp-primitives', 'wp-private-apis', 'wp-theme', 'wp-warning'), 'module_dependencies' => array(array('id' => '@wordpress/a11y', 'import' => 'static'), array('id' => '@wordpress/route', 'import' => 'static')), 'version' => '66d296b87fc4086736e2');

src/wp-includes/build/routes/post-list/content.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)