问题标签 [relative-time-span]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
729 浏览

ruby - 如何计算红宝石的相对时间?

如何在红宝石中计算秒、分钟、天、月和年的relative_time?

如何在红宝石中实现这一点?请帮忙

0 投票
1 回答
252 浏览

momentjs - 如何配置 @nuxtjs/moment 以使用相对时间设置为 en locale

  • 我正在尝试使用 moment(...).fromNow() 来显示相对时间
  • 我正在使用@nuxtjs/moment模块
  • 它目前将相对时间显示为“15 天前”等。我想将其更改为“15 d”

根据这个答案是目前如何完成

如何将其应用于 @nuxtjs/moment 模块

0 投票
3 回答
80 浏览

java - 如何使用 Java 获取多个值的输入?

使用文森特罗伯特的回答,我想用 Java 重建它。

我是这样开始的:

现在在main()函数中,我想做一些与 C's 类似的事情scanf("%d/%d/%d", &mon, &day, &year);。如何使用单行在 Java 中实现类似的东西?

我期待这种输入:

0 投票
2 回答
76 浏览

java - How to calculate relative time spans using Java (code converting problem)?

I decided to give myself a challenge on Java that implements this question's achievement.

The things I have to do is get LocalDateTime, convert the same code from the linked question's answers, then receiving a string from the function.

Here's what I've done so far:

The only problem that I should encounter is from var ts = new TimeSpan(DateTime.UtcNow.Ticks - yourDate.Ticks);.

Although I read 2 questions from Stack Overflow finding equivalents of TimeSpan and Ticks, I baely have any ideas how to properly convert the line of code. Also, I have to get a double which will need math.abs() to get TotalSeconds which I can't really find a proper way to deal with either, but I did find ZoneOffset.ofTotalSeconds and still don't know how to deal with it.

So how can I convert this properly?

0 投票
3 回答
129 浏览

python - Python如何合并时间跨度并制作更大的时间跨度

我有以下数据框。

我想在两者之间选择最长的时间跨度。我想要的输出应该是这样的

我不在乎持续时间。我能做到。但是我将如何合并重叠的时间跨度。谢谢