本文整理汇总了TypeScript中d3-time-format.timeFormat函数的典型用法代码示例。如果您正苦于以下问题:TypeScript timeFormat函数的具体用法?TypeScript timeFormat怎么用?TypeScript timeFormat使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了timeFormat函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: buildNotification
function buildNotification(trade, error) {
if (error) {
return { message: error, hasError: true, notificationType: NotificationType.Text }
}
return {
notificationType: NotificationType.Trade,
hasError: false,
direction: trade.direction === Direction.Sell ? 'Sold' : 'Bought',
notional: numeral(trade.notional).format('0,000,000[.]00'),
status: trade.status,
dealtCurrency: trade.currencyPair.base,
termsCurrency: trade.currencyPair.terms,
spotRate: trade.spotRate,
formattedValueDate: `SP. ${timeFormat('%b %e')(trade.valueDate)}`,
tradeId: trade.tradeId,
}
}
示例2: Date
let formatFn: (n: Date) => string;
let parseFn: (dateString: string) => (Date | null);
let localeDef: d3TimeFormat.TimeLocaleDefinition;
let localeObj: d3TimeFormat.TimeLocaleObject;
// ----------------------------------------------------------------------
// Test Formating and Parsing
// ----------------------------------------------------------------------
// local time -----------------------------------------------------------
formatFn = d3TimeFormat.timeFormat('.%L');
parseFn = d3TimeFormat.timeParse('.%L');
// utc ------------------------------------------------------------------
formatFn = d3TimeFormat.utcFormat('.%L');
parseFn = d3TimeFormat.utcParse('.%L');
// iso ------------------------------------------------------------------
const dateString: string = d3TimeFormat.isoFormat(new Date(2016, 6, 6));
const date: Date | null = d3TimeFormat.isoParse('2016-07-08T14:06:41.386Z');
// ----------------------------------------------------------------------
// Test Locale Definition
// ----------------------------------------------------------------------
示例3: constructor
constructor(id: string, desc: Readonly<IDateMapColumnDesc>) {
super(id, desc);
this.format = timeFormat(desc.dateFormat || '%x');
this.parse = desc.dateParse ? timeParse(desc.dateParse) : timeParse(desc.dateFormat || '%x');
this.setDefaultRenderer('default');
}
示例4: timeFormat
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { timeFormat } from 'd3-time-format';
const formatDate = timeFormat('%Y-%m-%d %H:%M:%S.%L');
export function formatTime(time: number) {
return formatDate(new Date(time));
}
示例5: formatDate
export function formatDate(date: any, format:string = '%b %e, %H:%M:%S') {
return timeFormat(format)(date)
}