How to use the @wordpress/date.__experimentalGetSettings function in @wordpress/date

To help you get started, we’ve selected a few @wordpress/date examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WordPress / gutenberg / packages / editor / src / components / post-schedule / index.js View on Github external
export function PostSchedule( { date, onUpdateDate } ) {
	const settings = __experimentalGetSettings();
	// To know if the current timezone is a 12 hour time with look for "a" in the time format
	// We also make sure this a is not escaped by a "/"
	const is12HourTime = /a(?!\\)/i.test(
		settings.formats.time
			.toLowerCase() // Test only the lower case a
			.replace( /\\\\/g, '' ) // Replace "//" with empty strings
			.split( '' ).reverse().join( '' ) // Reverse the string and test for "a" not followed by a slash
	);

	return (
github ampproject / amp-wp / assets / src / stories-editor / components / with-meta-block-edit.js View on Github external
} = useSelect( ( select ) => {
		const { getEditedPostAttribute } = select( 'core/editor' );
		const { getAuthors } = select( 'core' );
		const { getSettings } = select( 'core/block-editor' );

		const attributeValue = getEditedPostAttribute( attribute );

		let blockContent;
		let loading = false;

		// Todo: Maybe pass callbacks as props instead.
		switch ( attribute ) {
			case 'date':
				const dateSettings = getDateSettings();
				const dateFormat = dateSettings.formats.date;
				const date = attributeValue || new Date();

				blockContent = dateI18n( dateFormat, date );

				break;
			case 'author':
				const author = getAuthors().find( ( { id } ) => id === attributeValue );

				blockContent = author ? author.name : __( 'Anonymous', 'amp' );
				loading = ! author;

				break;
			default:
				blockContent = attributeValue;
		}
github godaddy-wordpress / coblocks / src / blocks / posts / edit.js View on Github external
const hasFeaturedImage = some( displayPosts, 'featured_media_object' );

		const toolbarControls = [ {
			icon: icons.imageLeft,
			title: __( 'Image on left', 'coblocks' ),
			isActive: listPosition === 'left',
			onClick: () => setAttributes( { listPosition: 'left' } ),
		}, {
			icon: icons.imageRight,
			title: __( 'Image on right', 'coblocks' ),
			isActive: listPosition === 'right',
			onClick: () => setAttributes( { listPosition: 'right' } ),
		} ];

		const dateFormat = __experimentalGetSettings().formats.date; // eslint-disable-line no-restricted-syntax

		if ( ! hasPosts && postFeedType === 'internal' ) {
			return (
github pods-framework / pods / ui / js / blocks / src / blocks / components / BlockPreview.js View on Github external
}
		case 'DateTimePicker': {
			const dateFormat = __experimentalGetSettings().formats.datetime;

			return (
				<div name="">
					<time datetime="{">
						{ dateI18n( dateFormat, fieldValue ) }
					</time>
				</div>
			);
		}
		case 'NumberControl': {
			let { locale } = __experimentalGetSettings().l10n;

			locale = locale.replace( '_', '-' );

			return (
				<div name="">
					{ !! fieldValue &amp;&amp; fieldValue.toLocaleString( locale ) }
				</div>
			);
		}
		case 'MediaUpload': {
			return (
				<div name="">
					{ fieldValue &amp;&amp; fieldValue.url || 'N/A' }
				</div>
			);
		}
github WordPress / gutenberg / packages / editor / src / components / post-schedule / label.js View on Github external
export function PostScheduleLabel( { date, isFloating } ) {
	const settings = __experimentalGetSettings();

	return date && ! isFloating ?
		dateI18n( settings.formats.datetimeAbbreviated, date ) :
		__( 'Immediately' );
}
github pods-framework / pods / ui / js / blocks / src / blocks / components / BlockPreview.js View on Github external
<span value="">
										{ value.label }
										{ ( index &lt; values.length - 1 ) ? ', ' : '' }
									</span>
								)
							} )
							: 'N/A' }
					
				);
			}
		}
		case 'DateTimePicker': {
			const dateFormat = __experimentalGetSettings().formats.datetime;

			return (
				<div name="">
					<time datetime="{">
						{ dateI18n( dateFormat, fieldValue ) }
					</time>
				</div>
			);
		}
		case 'NumberControl': {
			let { locale } = __experimentalGetSettings().l10n;

			locale = locale.replace( '_', '-' );
github Automattic / jetpack / extensions / blocks / business-hours / edit.js View on Github external
const { days } = attributes;
		const { localization, hasFetched } = this.state;
		const { startOfWeek } = localization;
		const localizedWeek = days.concat( days.slice( 0, startOfWeek ) ).slice( startOfWeek );

		if ( ! hasFetched ) {
			return (
				 }
					label={ __( 'Loading business hours', 'jetpack' ) }
				/&gt;
			);
		}

		if ( ! isSelected ) {
			const settings = __experimentalGetSettings();
			const {
				formats: { time },
			} = settings;
			return (
				<dl>
					{ localizedWeek.map( ( day, key ) =&gt; {
						return (
							
						);
					} ) }
				</dl>
github Automattic / wp-calypso / packages / jetpack-blocks / src / blocks / business-hours / edit.jsx View on Github external
const { days } = attributes;
		const { localization, hasFetched } = this.state;
		const { startOfWeek } = localization;
		const localizedWeek = days.concat( days.slice( 0, startOfWeek ) ).slice( startOfWeek );

		if ( ! hasFetched ) {
			return (
				 }
					label={ __( 'Loading business hours' ) }
				/&gt;
			);
		}

		if ( ! isSelected ) {
			const settings = __experimentalGetSettings();
			const {
				formats: { time },
			} = settings;
			return (
				<dl>
					{ localizedWeek.map( ( day, key ) =&gt; {
						return (
							
						);
					} ) }
				</dl>
github ampproject / amp-wp / assets / src / stories-editor / components / block-preview-label.js View on Github external
.replace( /&lt;[^&lt;&gt;]+&gt;/g, '' )
					.slice( 0, 30 );
			}

			label = content.length &gt; 0 ? content : blockType.title;
			break;

		case 'amp/amp-story-post-author':
			const author = getAuthors().find( ( { id } ) =&gt; id === getEditedPostAttribute( 'author' ) );

			label = author ? author.name : __( 'Post Author', 'amp' );
			break;

		case 'amp/amp-story-post-date':
			const postDate = getEditedPostAttribute( 'date' );
			const dateSettings = getDateSettings();
			const dateFormat = dateSettings.formats.date;
			const date = postDate || new Date();

			label = dateI18n( dateFormat, date );
			break;

		case 'amp/amp-story-post-title':
			label = getEditedPostAttribute( 'title' ) || blockType.title;
			break;

		default:
			break;
	}

	return {
		content: label,