本文整理汇总了TypeScript中moment.duration函数的典型用法代码示例。如果您正苦于以下问题:TypeScript duration函数的具体用法?TypeScript duration怎么用?TypeScript duration使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了duration函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: processOptions
/* Options
------------------------------------------------------------------------------------------------------------------*/
// Parses various options into properties of this object
processOptions() {
let slotDuration = this.opt('slotDuration')
let snapDuration = this.opt('snapDuration')
let input
slotDuration = moment.duration(slotDuration)
snapDuration = snapDuration ? moment.duration(snapDuration) : slotDuration
this.slotDuration = slotDuration
this.snapDuration = snapDuration
this.snapsPerSlot = slotDuration / snapDuration // TODO: ensure an integer multiple?
// might be an array value (for TimelineView).
// if so, getting the most granular entry (the last one probably).
input = this.opt('slotLabelFormat')
if ($.isArray(input)) {
input = input[input.length - 1]
}
this.labelFormat = input ||
this.opt('smallTimeFormat') // the computed default
input = this.opt('slotLabelInterval')
this.labelInterval = input ?
moment.duration(input) :
this.computeLabelInterval(slotDuration)
}
开发者ID:enhazappe,项目名称:fullcalendar,代码行数:32,代码来源:TimeGrid.ts
示例2: run
public async run(msg: CommandMessage): Promise<Message | Message[]> {
if (msg.channel instanceof TextChannel &&
!msg.channel.permissionsFor(this.client.user).has('SEND_MESSAGES')) {
return
}
const statsDisplay = stripIndents`
Guilds: ${this.client.guilds.size}
Channels: ${this.client.channels.size}
Users: ${this.client.guilds.map((g: Guild) => g.memberCount).reduce((a, b) => a + b)}
`
if (msg.channel instanceof TextChannel &&
!msg.channel.permissionsFor(this.client.user).has('EMBED_LINKS')) {
return msg.say(stripIndents`
**${this.client.user.username} Statistics**
**Uptime**
${moment.duration(this.client.uptime).humanize()}
**Memory Usage**
${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)}MB
**General Stats**
${statsDisplay}
`)
}
return msg.embed(
new RichEmbed()
.setTitle(`${this.client.user.username} Statistics`)
.setThumbnail(this.client.user.displayAvatarURL)
.addField('Uptime', moment.duration(this.client.uptime).humanize(), true)
.addField('Memory Usage', `${Math.round(process.memoryUsage().heapUsed / 1024 / 1024)}MB`, true)
.addField('General Stats', statsDisplay, true)
)
}
开发者ID:tinnvec,项目名称:stonebot,代码行数:34,代码来源:stats.ts
示例3:
export const init = (props: ITimeUtilsInitProps) => {
backgroundDuration = moment
.duration(props.backgroundTime, 'minutes')
.asMilliseconds()
modalDuration = moment.duration(props.modalTime, 'minutes').asMilliseconds()
defaultCallback = props.defaultCallback
hideModal = props.hideModal
onTimerEnd = props.onTimerEnd
}
开发者ID:appirio-digital,项目名称:react-native-session-timer-modal,代码行数:9,代码来源:utils.ts
示例4: it
it("should create the correct action to set time window settings", function() {
const payload: timewindow.TimeScale = {
windowSize: moment.duration(10, "s"),
windowValid: moment.duration(10, "s"),
sampleSize: moment.duration(10, "s"),
};
assert.deepEqual(
timewindow.setTimeScale(payload),
{ type: timewindow.SET_SCALE, payload },
);
});
开发者ID:duzhanyuan,项目名称:cockroach,代码行数:11,代码来源:timewindow.spec.ts
示例5: findId
(item: RegimenItem): RegimenItemCalendarRow => {
const uuid = findId(index, "Sequence", item.sequence_id);
const sequence = findSequence(index, uuid);
const { time_offset } = item;
const d = moment.duration(time_offset);
const { name } = sequence.body;
const color = sequence.body.color || randomColor();
const hhmm = moment({ hour: d.hours(), minute: d.minutes() }).format(FMT);
const day = Math.floor(moment.duration(time_offset).asDays()) + 1;
return { name, hhmm, color, day, dispatch, regimen, item, sortKey: time_offset };
};
开发者ID:RickCarlino,项目名称:farmbot-web-app,代码行数:11,代码来源:state_to_props.ts
示例6: computeSnapTime
// Given a row number of the grid, representing a "snap", returns a time (Duration) from its start-of-day
computeSnapTime(snapIndex) {
let slots = this.slots
if (slots && this.snapOnSlots) {
let start = this.view.calendar.msToUtcMoment(this.dateProfile.renderUnzonedRange.startMs)
let beginTime = start.clone()
let rowTime = start.clone().time(slots[Math.min(snapIndex, slots.length - 1)].start)
return moment.duration(rowTime.diff(beginTime))
} else {
return moment.duration(this.dateProfile.minTime + this.snapDuration * snapIndex)
}
}
开发者ID:kleisauke,项目名称:fullcalendar,代码行数:12,代码来源:TimeGrid.ts
示例7: multiplyDuration
export function multiplyDuration(dur, n) {
let months
if (durationHasTime(dur)) {
return moment.duration(dur * n)
}
months = dur.asMonths()
if (Math.abs(months) >= 1 && isInt(months)) {
return moment.duration({ months: months * n })
}
return moment.duration({ days: dur.asDays() * n })
}
开发者ID:enhazappe,项目名称:fullcalendar,代码行数:12,代码来源:util.ts
示例8: buildDateIncrement
// Compute the duration value that should be added/substracted to the current date
// when a prev/next operation happens.
buildDateIncrement(fallback) {
let dateIncrementInput = this.opt('dateIncrement')
let customAlignment
if (dateIncrementInput) {
return moment.duration(dateIncrementInput)
} else if ((customAlignment = this.opt('dateAlignment'))) {
return moment.duration(1, customAlignment)
} else if (fallback) {
return fallback
} else {
return moment.duration({ days: 1 })
}
}
开发者ID:caseyjhol,项目名称:fullcalendar,代码行数:16,代码来源:DateProfileGenerator.ts
示例9: getMomentDuration
export function getMomentDuration(timeSpan: string): Duration | null {
const
litRegex = /((\d*)\.)?(\d{2}):(\d{2}):(\d{2})(\.(\d{0,3}))?/,
isoRegex = /^P(([\d\.]+)Y)?(([\d\.]+)M)?(([\d\.]+)D)?T(([\d\.]+)H)?(([\d\.]+)M)?(([\d\.]+)S)?$/;
let matches: RegExpMatchArray | null,
options: DurationInputObject | undefined;
if (matches = timeSpan.match(isoRegex)) {
options = {
years: matches[1] ? parseFloat(matches[2]) : 0,
months: matches[3] ? parseFloat(matches[4]) : 0,
days: matches[5] ? parseFloat(matches[6]) : 0,
hours: matches[7] ? parseFloat(matches[8]) : 0,
minutes: matches[9] ? parseFloat(matches[10]) : 0,
seconds: matches[11] ? parseFloat(matches[12]) : 0
};
}
else if (matches = timeSpan.match(litRegex)) {
options = {
milliseconds: matches[7] ? parseInt(matches[7], 10) : 0,
seconds: matches[5] ? parseInt(matches[5], 10) : 0,
minutes: matches[4] ? parseInt(matches[4], 10) : 0,
hours: matches[3] ? parseInt(matches[3], 10) : 0,
days: matches[2] ? parseInt(matches[2], 10) : 0
};
}
return options ?
moment.duration(options) :
null;
}
开发者ID:spatools,项目名称:komoment,代码行数:32,代码来源:core.ts
示例10: transform
transform(value: number, args?: any): any {
if (isNaN(Number.parseInt(value as any))) {
return value;
}
const leftmostPair = [];
const time = moment.duration(value, "milliseconds");
const order = ["years", "months", "days", "hours", "minutes", "seconds", "milliseconds"];
const short = ["y", "m", "d", "h", "min", "s", "ms"];
for (let i = 0; i < order.length; i++) {
const amount = time.get(order[i] as any);
if (amount > 0) {
leftmostPair.push(amount + short[i]);
}
if (leftmostPair.length >= 2) {
break;
}
}
return leftmostPair.join(" ");
}
开发者ID:hmenager,项目名称:composer,代码行数:29,代码来源:execution-duration.pipe.ts
注:本文中的moment.duration函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论