diff --git a/vasl_templates/webapp/data/default-template-pack/scenario.j2 b/vasl_templates/webapp/data/default-template-pack/scenario.j2 index d65d84c..13aa207 100755 --- a/vasl_templates/webapp/data/default-template-pack/scenario.j2 +++ b/vasl_templates/webapp/data/default-template-pack/scenario.j2 @@ -15,10 +15,10 @@ {%if SCENARIO_LOCATION%} ({{SCENARIO_LOCATION}}) {%endif%} {%if SCENARIO_DATE%} - ({{SCENARIO_MONTH_NAME}} {{SCENARIO_DAY_OF_MONTH}}, {{SCENARIO_YEAR}}) + ({{SCENARIO_MONTH_NAME}} {{SCENARIO_DAY_OF_MONTH_POSTFIX}}, {{SCENARIO_YEAR}}) {%endif%} - \ No newline at end of file + diff --git a/vasl_templates/webapp/static/snippets.js b/vasl_templates/webapp/static/snippets.js index 108e379..9ff2b23 100644 --- a/vasl_templates/webapp/static/snippets.js +++ b/vasl_templates/webapp/static/snippets.js @@ -8,6 +8,11 @@ var _MONTH_NAMES = [ // nb: we assume English :-/ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ] ; +var _DAY_OF_MONTH_POSTFIXES = { // nb: we assume English :-/ + 0: "th", + 1: "st", 2: "nd", 3: "rd", 4: "th", 5: "th", 6: "th", 7: "th", 8: "th", 9: "th", 10: "th", + 11: "th", 12: "th", 13: "th" +} ; // -------------------------------------------------------------------- @@ -53,8 +58,14 @@ function generate_snippet( $btn ) // extract the scenario date components var scenario_date = $("input[name='SCENARIO_DATE']").datepicker( "getDate" ) ; + var postfix ; if ( scenario_date ) { params.SCENARIO_DAY_OF_MONTH = scenario_date.getDate() ; + if ( params.SCENARIO_DAY_OF_MONTH in _DAY_OF_MONTH_POSTFIXES ) + postfix = _DAY_OF_MONTH_POSTFIXES[ params.SCENARIO_DAY_OF_MONTH ] ; + else + postfix = _DAY_OF_MONTH_POSTFIXES[ params.SCENARIO_DAY_OF_MONTH % 10 ] ; + params.SCENARIO_DAY_OF_MONTH_POSTFIX = params.SCENARIO_DAY_OF_MONTH + postfix ; params.SCENARIO_MONTH = 1 + scenario_date.getMonth() ; params.SCENARIO_MONTH_NAME = _MONTH_NAMES[scenario_date.getMonth()] ; params.SCENARIO_YEAR = scenario_date.getFullYear() ;