You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi there, it seems that the TimespanFormatter abbreviated format does not work correctly for time spans beyond a week. Wondering if this was intentional by design?
Works correctly: tsf.format(400000, {direction: "none", type: "abbreviated"}) "5d"
Breaks: tsf.format(700000, {direction: "none", type: "abbreviated"}) VM89:14 Uncaught TypeError: Cannot read property 'one' of undefined at t.eval (eval at <anonymous> (http://local-change.org:3000/public/js/changeAssets.js:11502:5), <anonymous>:14:8229) at t.e.TimespanFormatter.t.format (eval at <anonymous> (http://local-change.org:3000/public/js/changeAssets.js:11502:5), <anonymous>:14:8303) at <anonymous>:2:22 at Object.InjectedScript._evaluateOn (<anonymous>:895:140) at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34) at Object.InjectedScript.evaluate (<anonymous>:694:21)
The text was updated successfully, but these errors were encountered:
@krnwonseungee hey, it's definitely a bug, but it's a tricky one.
Looks like the problem is that if you don't specify units explicitly, TimespanFormatter tries to guess them and pick the largest one that fits into your time span. In your example it picks days for 1-7 days, but starting from 8 days it tries to format your time span in weeks. Unfortunately, we have data for abbreviated format only for days, but not for weeks, so it fails to return an abbreviated string once your time span is bigger than a week.
There are two possible workarounds here: either use short format (which is slightly longer than abbreviated) or pass day as desired time unit (examples are in Russian):
fmt.format(100000,{direction: "none",type: "short"})// => "1 дн." - short for "1 day"fmt.format(700000,{direction: "none",type: "short"})// => "1 нед." - short for "1 week"fmt.format(100000,{unit: "day",direction: "none",type: "abbreviated"})// => "1 д"fmt.format(700000,{unit: "day",direction: "none",type: "abbreviated"})// => "8 д"
I'll definitely work on a permanent fix for the issue, but it might be a while before I get to it, so if either of the options above is acceptable for you, I'd suggest using it for the time being.
Hi there, it seems that the TimespanFormatter abbreviated format does not work correctly for time spans beyond a week. Wondering if this was intentional by design?
Works correctly:
tsf.format(400000, {direction: "none", type: "abbreviated"}) "5d"
tsf.format(500000, {direction: "none", type: "abbreviated"}) "6d"
tsf.format(600000, {direction: "none", type: "abbreviated"}) "7d"
Breaks:
tsf.format(700000, {direction: "none", type: "abbreviated"}) VM89:14 Uncaught TypeError: Cannot read property 'one' of undefined at t.eval (eval at <anonymous> (http://local-change.org:3000/public/js/changeAssets.js:11502:5), <anonymous>:14:8229) at t.e.TimespanFormatter.t.format (eval at <anonymous> (http://local-change.org:3000/public/js/changeAssets.js:11502:5), <anonymous>:14:8303) at <anonymous>:2:22 at Object.InjectedScript._evaluateOn (<anonymous>:895:140) at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34) at Object.InjectedScript.evaluate (<anonymous>:694:21)
The text was updated successfully, but these errors were encountered: