PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Admin / common / formatToDateLocalInput.ts

formatToDateLocalInput.ts in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/Admin/common/formatToDateLocalInput.ts

21 lines 549 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import {dateI18n, getDate} from '@wordpress/date';
2
3 /**
4 * Format the date to a date-local input compatible string
5 * @since 4.13.0
6 */
7 export default function formatToDateLocalInput(dateString: string) {
8 if (!dateString) {
9 return '';
10 }
11
12 // Interpret server-provided naive strings as site timezone (WordPress timezone),
13 // and preserve the wall time for the date input.
14 const dateObj = getDate(dateString);
15 if (isNaN(dateObj.getTime())) {
16 return '';
17 }
18
19 return dateI18n('Y-m-d', dateObj, undefined);
20 }
21