Commit b686b3d5 authored by Kushal Pandya's avatar Kushal Pandya

Convert methods to ES6 exports

parent f5d71ad8
...@@ -74,10 +74,9 @@ let timeagoInstance; ...@@ -74,10 +74,9 @@ let timeagoInstance;
/** /**
* Sets a timeago Instance * Sets a timeago Instance
*/ */
export function getTimeago() { export const getTimeago = () => {
if (!timeagoInstance) { if (!timeagoInstance) {
const localeRemaining = function getLocaleRemaining(number, index) { const localeRemaining = (number, index) => [
return [
[s__('Timeago|just now'), s__('Timeago|right now')], [s__('Timeago|just now'), s__('Timeago|right now')],
[s__('Timeago|%s seconds ago'), s__('Timeago|%s seconds remaining')], [s__('Timeago|%s seconds ago'), s__('Timeago|%s seconds remaining')],
[s__('Timeago|1 minute ago'), s__('Timeago|1 minute remaining')], [s__('Timeago|1 minute ago'), s__('Timeago|1 minute remaining')],
...@@ -93,9 +92,8 @@ export function getTimeago() { ...@@ -93,9 +92,8 @@ export function getTimeago() {
[s__('Timeago|1 year ago'), s__('Timeago|1 year remaining')], [s__('Timeago|1 year ago'), s__('Timeago|1 year remaining')],
[s__('Timeago|%s years ago'), s__('Timeago|%s years remaining')], [s__('Timeago|%s years ago'), s__('Timeago|%s years remaining')],
][index]; ][index];
};
const locale = function getLocale(number, index) { const locale = (number, index) => [
return [
[s__('Timeago|just now'), s__('Timeago|right now')], [s__('Timeago|just now'), s__('Timeago|right now')],
[s__('Timeago|%s seconds ago'), s__('Timeago|in %s seconds')], [s__('Timeago|%s seconds ago'), s__('Timeago|in %s seconds')],
[s__('Timeago|1 minute ago'), s__('Timeago|in 1 minute')], [s__('Timeago|1 minute ago'), s__('Timeago|in 1 minute')],
...@@ -111,7 +109,6 @@ export function getTimeago() { ...@@ -111,7 +109,6 @@ export function getTimeago() {
[s__('Timeago|1 year ago'), s__('Timeago|in 1 year')], [s__('Timeago|1 year ago'), s__('Timeago|in 1 year')],
[s__('Timeago|%s years ago'), s__('Timeago|in %s years')], [s__('Timeago|%s years ago'), s__('Timeago|in %s years')],
][index]; ][index];
};
timeago.register(timeagoLanguageCode, locale); timeago.register(timeagoLanguageCode, locale);
timeago.register(`${timeagoLanguageCode}-remaining`, localeRemaining); timeago.register(`${timeagoLanguageCode}-remaining`, localeRemaining);
...@@ -184,7 +181,7 @@ export const getDayDifference = (a, b) => { ...@@ -184,7 +181,7 @@ export const getDayDifference = (a, b) => {
* @param {Number} seconds * @param {Number} seconds
* @return {String} * @return {String}
*/ */
export function timeIntervalInWords(intervalInSeconds) { export const timeIntervalInWords = (intervalInSeconds) => {
const secondsInteger = parseInt(intervalInSeconds, 10); const secondsInteger = parseInt(intervalInSeconds, 10);
const minutes = Math.floor(secondsInteger / 60); const minutes = Math.floor(secondsInteger / 60);
const seconds = secondsInteger - minutes * 60; const seconds = secondsInteger - minutes * 60;
...@@ -198,7 +195,7 @@ export function timeIntervalInWords(intervalInSeconds) { ...@@ -198,7 +195,7 @@ export function timeIntervalInWords(intervalInSeconds) {
return text; return text;
} }
export function dateInWords(date, abbreviated = false, hideYear = false) { export const dateInWords = (date, abbreviated = false, hideYear = false) => {
if (!date) return date; if (!date) return date;
const month = date.getMonth(); const month = date.getMonth();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment