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 / convertLocalDateTimeToISOString.ts

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

24 lines 789 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 * Convert a datetime-local string (e.g., "2025-10-21T15:30") to an ISO string.
4 *
5 * @since 4.13.0
6 */
7 export default function convertLocalDateTimeToISOString(localDateTime: string): string {
8 if (!localDateTime) {
9 return '';
10 }
11
12 // Interpret the provided wall time in the WordPress site timezone and
13 // return a site-local naive ISO-like string (no timezone). The server
14 // interprets naive strings in wp_timezone().
15 const date = getDate(localDateTime);
16 if (isNaN(date.getTime())) {
17 return '';
18 }
19
20 // Return RFC3339 with timezone offset to satisfy JSON Schema `date-time` validation
21 // Example: 2025-10-21T22:00:00-04:00
22 return dateI18n('Y-m-d\\TH:i:sP', date, undefined);
23 }
24