Rails中time_ago_in_words和distance_of_time_in_words的精度更高

时间:2021-06-29 13:20:10

Are there any options to make the time_ago_in_words or distance_of_time_in_words functions more precise in Rails? Their documentation mentions options but doesn't specify what they are.

是否有任何选项可以使Rails中的time_ago_in_words或distance_of_time_in_words函数更精确?他们的文档提到了选项,但没有说明它们是什么。

If I pass in times for 38 minutes, those functions will output 38 minutes, which is perfect. But if I pass in 89 minutes, I'll get back 'about 1 hour'. That's just too broad for my purposes, I want more granularity or precision.

如果我通过38分钟,这些功能将输出38分钟,这是完美的。但是如果我在89分钟内通过,我会回来'约1小时'。这对我的目的来说太宽泛了,我想要更多的粒度或精度。

1 个解决方案

#1


0  

I've used dotiw in this situation. It expands on the Rails version to provide you more control over the output.

我在这种情况下使用了dotiw。它扩展了Rails版本,为您提供更多的输出控制。

#1


0  

I've used dotiw in this situation. It expands on the Rails version to provide you more control over the output.

我在这种情况下使用了dotiw。它扩展了Rails版本,为您提供更多的输出控制。