import React from 'react';
import {dateI18n, __experimentalGetSettings} from '@wordpress/date';

class Date extends React.Component {
	render() {
		const {post, attributes} = this.props;

		const {displayPostDate, postDateTypography} = attributes;

		const dateFormat = __experimentalGetSettings().formats.date;

		return (
			displayPostDate &&
			post.date_gmt && (
				<div
					className="flo-block-post-grid__date"
					data-font={
						postDateTypography.type === 'theme' ? postDateTypography.theme : ''
					}
				>
					{dateI18n(dateFormat, post.date_gmt)}
				</div>
			)
		);
	}
}

export default Date;
