How to use the i18n-calypso.moment function in i18n-calypso

To help you get started, we’ve selected a few i18n-calypso 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 Automattic / wp-calypso / client / my-sites / stats / controller.jsx View on Github external
);
		} );

		if ( ! activeFilter ) {
			next();
		} else {
			if ( currentSite && currentSite.domain ) {
				// FIXME: Auto-converted from the Flux setTitle action. Please use  instead.
				context.store.dispatch( setTitle( i18n.translate( 'Stats', { textOnly: true } ) ) );
			}

			const gmtOffset = getSiteOption( context.store.getState(), siteId, 'gmt_offset' );
			const momentSiteZone = i18n
				.moment()
				.utcOffset( Number.isFinite( gmtOffset ) ? gmtOffset : 0 );
			if ( queryOptions.startDate && i18n.moment( queryOptions.startDate ).isValid() ) {
				date = i18n.moment( queryOptions.startDate ).locale( 'en' );
				numPeriodAgo = getNumPeriodAgo( momentSiteZone, date, activeFilter.period );
			} else {
				date = rangeOfPeriod( activeFilter.period, momentSiteZone.locale( 'en' ) ).startOf;
			}

			numPeriodAgo = parseInt( numPeriodAgo, 10 );
			if ( numPeriodAgo ) {
				if ( numPeriodAgo > 9 ) {
					numPeriodAgo = '10plus';
				}
				numPeriodAgo = '-' + numPeriodAgo;
			} else {
				numPeriodAgo = '';
			}
github Automattic / wp-calypso / client / lib / posts / utils.js View on Github external
export const getOffsetDate = function( date, tz ) {
	if ( ! tz ) {
		return moment( date );
	}

	return moment( moment.tz( date, tz ) );
};
github Automattic / wp-calypso / client / lib / stats / stats-list / stats-parser.js View on Github external
function rangeOfPeriod( period, date ) {
	date = new i18n.moment( date );
	var periodRange = { period: period,
		startOf: date.clone().startOf( period ),
		endOf: date.clone().endOf( period )
	};

	if ( 'week' === period ) {
		if ( '0' === date.format( 'd' ) ) {
			periodRange.startOf.subtract( 6, 'd' );
		} else {
			periodRange.startOf.add( 1, 'd' );
			periodRange.endOf.add( 1, 'd' );
		}
	}
	return periodRange;
}
github Automattic / wp-calypso / client / me / help / help-contact-closed / index.jsx View on Github external
const BusinessPlanMessage = ( { translate } ) => {
	const message = [];

	if ( i18n.moment() < thanksgiving2018ClosureStartsAt ) {
		message.push(
			translate(
				"{{p}}Live chat will be closed on Thursday, November 22, 2018 for the US Thanksgiving holiday. If you need to get in touch with us, you’ll be able to submit a support request from this page and we'll respond by email. Live chat will reopen on November 23rd. Thank you!!{{/p}}",
				{
					components: {
						p: <p>,
					},
				}
			)
		);
	} else {
		message.push(
			translate(
				"{{p}}Live chat is closed today for the US Thanksgiving holiday. If you need to get in touch with us, submit a support request below and we'll respond by email. Live chat will reopen on November 23rd. Thank you!{{/p}}",
				{
					components: {</p>
github Automattic / wp-calypso / client / me / billing-history / table-rows.js View on Github external
transactions = transactions.filter( function( transaction ) {
				const date = moment( transaction.date );

				if ( params.date.month ) {
					return date.isSame( params.date.month, 'month' );
				} else if ( params.date.before ) {
					return date.isBefore( params.date.before, 'month' );
				}
			} );
		}
github Automattic / wp-calypso / client / lib / billing-history-data / index.js View on Github external
function parseDate( transaction ) {
	return assign( {}, transaction, {
		date: i18n.moment( transaction.date ).toDate()
	} );
};
github Automattic / wp-calypso / client / my-sites / plugins / plugin-meta / index.jsx View on Github external
isOutOfDate() {
		if ( this.props.plugin && this.props.plugin.last_updated ) {
			const lastUpdated = moment( this.props.plugin.last_updated, 'YYYY-MM-DD' );
			return moment().diff( lastUpdated, 'years' ) >= this.OUT_OF_DATE_YEARS;
		}
		return false;
	}
github Automattic / wp-calypso / client / me / help / chat-closure-notice / index.jsx View on Github external
const Notice = localize( ( { translate, closedFrom, closedTo, reason } ) =&gt; (
	<div>
		
			{ title( { translate, closedFrom, closedTo, reason } ) }
		
		<div>
			{ i18n.moment().isBefore( closedFrom )
				? upcoming( { translate, closedFrom, closedTo, reason } )
				: closed( { translate, closedFrom, closedTo, reason } ) }
		</div>
	</div>
) );
github Automattic / wp-calypso / client / me / account / main.jsx View on Github external
renderJoinDate() {
		const { translate } = this.props;
		const dateMoment = i18n.moment( user.get().date );

		return (
			<span>
				{
					translate( 'Joined %(month)s %(year)s', {
						args: {
							month: dateMoment.format( 'MMMM' ),
							year: dateMoment.format( 'YYYY' )
						}
					} )
				}
			</span>
		);
	},
github Automattic / wp-calypso / client / lib / posts / utils.js View on Github external
export const isBackDated = function( post ) {
	if ( ! post || ! post.date || ! post.modified ) {
		return false;
	}

	return moment( post.date ).isBefore( moment( post.modified ) );
};