Skip to content

Commit 58f2a99

Browse files
committed
ADds a new property to Datetime defaults to define the BC dates appendix to be used. Before this patch the appendix was selected using the first element of the available appendixes. Now the output appendix can be easily configured without modifying the list of available appendix
See #73181
1 parent 4ccbda9 commit 58f2a99

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/elements/DateTime/DateTime.coffee

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ class CUI.DateTime extends CUI.Input
1717

1818
@defaults:
1919
button_tooltip: "Open calendar"
20-
bc_appendix: ["B.C.","BC","V. CHR.","VCHR","VCHR."]
20+
bc_appendix: ["B.C.","BC","V. CHR.","VCHR","VCHR."] # BC appendixes to recognize
21+
bc_appendix_output: "B.C." # BC appendix to output
2122

2223
initOpts: ->
2324
super()
@@ -1478,11 +1479,11 @@ class CUI.DateTime extends CUI.Input
14781479
# BC appendix always adds one year. Therefore year 0 is 1 BC.
14791480
@formatMomentWithBc: (mom, format) ->
14801481
if mom.year() == 0
1481-
return "1 #{CUI.DateTime.defaults.bc_appendix[0]}"
1482+
return "1 #{CUI.DateTime.defaults.bc_appendix_output}"
14821483

14831484
if mom.bc
14841485
bc = parseInt(mom.bc) + 1
1485-
return "#{(bc)} #{CUI.DateTime.defaults.bc_appendix[0]}"
1486+
return "#{(bc)} #{CUI.DateTime.defaults.bc_appendix_output}"
14861487

14871488
if mom.year() > 0
14881489
v = mom.format(format)
@@ -1492,7 +1493,7 @@ class CUI.DateTime extends CUI.Input
14921493
return v.replace(regexp, ""+mom.year())
14931494

14941495
mom.subtract(1, "year")
1495-
v = mom.format(format) + " " + CUI.DateTime.defaults.bc_appendix[0]
1496+
v = mom.format(format) + " " + CUI.DateTime.defaults.bc_appendix_output
14961497
# remove the "-" and all possible zeros.
14971498
replace = "\\-0*#{-1 * mom.year()}";
14981499
regexp = new RegExp(replace);

0 commit comments

Comments
 (0)