Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function formatter(pattern) { // eslint-disable-line import/prefer-default-export
let locale = timeFormatLocale({
dateTime: '%x, %X',
date: '%-m/%-d/%Y',
time: '%-I:%M:%S %p',
periods: ['AM', 'PM'],
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
});
let d3format = locale.format(pattern);
/**
* Format a value according to the specified pattern created at construct
*
* @param {Date} value The number to be formatted
let shortDays: [string, string, string, string, string, string, string] = localeDef.shortDays;
let months: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.months;
let shortMonths: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.shortMonths;
localeDef = {
dateTime: '%a %b %e %X %Y',
date: '%m/%d/%Y',
time: '%H:%M:%S',
periods: ['Vormittag', 'Nachmittag'],
days: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Sonnabend'],
shortDays: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
months: ['Januar', 'Februar', 'Maerz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
shortMonths: ['Jan', 'Feb', 'Mrz', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']
};
localeObj = d3TimeFormat.timeFormatLocale(localeDef);
localeObj = d3TimeFormat.timeFormatDefaultLocale(localeDef);
let formatFactory: (specifier: string) => ((date: Date) => string) = localeObj.format;
let parseFactory: (specifier: string) => ((dateString: string) => Date) = localeObj.parse;
formatFactory = localeObj.utcFormat;
parseFactory = localeObj.utcParse;
let shortDays: [string, string, string, string, string, string, string] = localeDef.shortDays;
let months: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.months;
let shortMonths: [string, string, string, string, string, string, string, string, string, string, string, string] = localeDef.shortMonths;
localeDef = {
dateTime: '%a %b %e %X %Y',
date: '%m/%d/%Y',
time: '%H:%M:%S',
periods: ['Vormittag', 'Nachmittag'],
days: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Sonnabend'],
shortDays: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
months: ['Januar', 'Februar', 'Maerz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
shortMonths: ['Jan', 'Feb', 'Mrz', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']
};
localeObj = d3TimeFormat.timeFormatLocale(localeDef);
localeObj = d3TimeFormat.timeFormatDefaultLocale(localeDef);
let formatFactory: (specifier: string) => ((date: Date) => string) = localeObj.format;
let parseFactory: (specifier: string) => ((dateString: string) => Date) = localeObj.parse;
formatFactory = localeObj.utcFormat;
parseFactory = localeObj.utcParse;
format.locale = function localeFn(...args) {
locale = timeFormatLocale(...args);
d3format = locale.format(pattern);
return this;
};
import React from 'react'
import {css} from 'glamor'
import { timeFormatLocale } from 'd3-time-format'
import timeDefinition from 'd3-time-format/locale/de-CH'
import { imageResizeUrl } from 'mdast-react-render/lib/utils'
import { H3 } from './Headlines'
import P from './Paragraph'
const timeFormat = timeFormatLocale(timeDefinition).format
const containerStyle = css({
height: '100%',
backgroundColor: '#f2f2f2',
maxWidth: 290
})
const imageStyle = css({
display: 'block',
'& img': {
width: '100%'
}
})
const textStyle = css({
display: 'block',
padding: '5px 10px 10px',
textDecoration: 'none',
import React from 'react'
import {css} from 'glamor'
import { timeFormatLocale } from 'd3-time-format'
import timeDefinition from 'd3-time-format/locale/de-CH'
import { imageResizeUrl } from 'mdast-react-render/lib/utils'
import { H3 } from './Headlines'
import P from './Paragraph'
const timeFormat = timeFormatLocale(timeDefinition).format
const containerStyle = css({
height: '100%',
backgroundColor: '#f2f2f2'
})
const imageStyle = css({
display: 'block',
'& img': {
width: '100%'
}
})
const textStyle = css({
display: 'block',
padding: '5px 10px 10px',
textDecoration: 'none',
'& p': {
if (String(Math.round(value)).length > 4) {
return chf5Format(value)
}
return chf4Format(value)
}
const count4Format = swissNumbers.format(',.0f')
const count5Format = swissNumbers.format(',.0f')
export const countFormat = value => {
if (String(Math.round(value)).length > 4) {
return count4Format(value)
}
return count5Format(value)
}
export const swissTime = timeFormatLocale({
'dateTime': '%A, der %e. %B %Y, %X',
'date': '%d.%m.%Y',
'time': '%H:%M:%S',
'periods': ['AM', 'PM'],
'days': ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
'shortDays': ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
'months': ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
'shortMonths': ['Jan', 'Feb', 'Mrz', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']
})
export const timeFormat = swissTime.format
const dateFormat = '%d.%m.%Y'
export const parseDate = swissTime.parse(dateFormat)
if (String(Math.round(value)).length > 4) {
return chf5Format(value)
}
return chf4Format(value)
}
const count4Format = swissNumbers.format('.0f')
const count5Format = swissNumbers.format(',.0f')
export const countFormat = value => {
if (String(Math.round(value)).length > 4) {
return count5Format(value)
}
return count4Format(value)
}
export const swissTime = timeFormatLocale(timeDefinition)
export const timeFormat = swissTime.format
const dateFormat = '%d.%m.%Y'
export const parseDate = swissTime.parse(dateFormat)
export const formatExcerpt = string =>
'... ' + string.replace(/\.+$/, '') + '...'
import { timeFormatLocale } from 'd3-time-format'
import timeDefinition from 'd3-time-format/locale/de-CH'
const locale = timeFormatLocale(timeDefinition)
export const timeFormat = locale.format
export const timeParse = locale.parse
const {
description,
formatString = isRequired('formatString'),
label,
locale,
useLocalTime = false,
} = config;
const id = useLocalTime ? `${LOCAL_PREFIX}${formatString}` : formatString;
let formatFunc;
if (typeof locale === 'undefined') {
const format = useLocalTime ? timeFormat : utcFormat;
formatFunc = format(formatString);
} else {
const localeObject = timeFormatLocale(locale);
formatFunc = useLocalTime
? localeObject.format(formatString)
: localeObject.utcFormat(formatString);
}
return new TimeFormatter({
description,
formatFunc,
id,
label,
useLocalTime,
});
}