← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6196: Moved date formats from resource bundles to java codeto avoid risk of invalid date formats in tra...

 

------------------------------------------------------------
revno: 6196
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-03-07 11:32:33 +0100
message:
  Moved date formats from resource bundles to java codeto avoid risk of invalid date formats in translations
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/popup.vm
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataArchiveForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/patientDataArchiveForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm
  dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewPivotTableForm.vm
  dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java	2012-01-18 04:58:32 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/i18n/I18nFormat.java	2012-03-07 10:32:33 +0000
@@ -50,6 +50,10 @@
     private static final String NAN = "NaN";
     private static final String INVALID_DATE="Invalid date format";
     
+    public static final String FORMAT_DATE = "yyyy-MM-dd";
+    public static final String FORMAT_TIME = "HH:mm";
+    public static final String FORMAT_DATETIME = "yyyy-MM-dd HH:mm";
+    
     private ResourceBundle resourceBundle;
 
     public I18nFormat( ResourceBundle resourceBundle )
@@ -115,7 +119,7 @@
             return null;
         }
 
-        return commonParsing( date, resourceBundle.getString( "format.date" ) );
+        return commonParsing( date, FORMAT_DATE );
     }
 
     public Date parseTime( String time )
@@ -125,7 +129,7 @@
             return null;
         }
 
-        return commonParsing( time, resourceBundle.getString( "format.time" ) );
+        return commonParsing( time, FORMAT_TIME );
     }
 
     public Date parseDateTime( String dateTime )
@@ -135,7 +139,7 @@
             return null;
         }
 
-        return commonParsing( dateTime, resourceBundle.getString( "format.datetime" ) );
+        return commonParsing( dateTime, FORMAT_DATETIME );
     }
 
     public String formatDate( Date date )
@@ -145,7 +149,7 @@
             return null;
         }
 
-        return commonFormatting( date, resourceBundle.getString( "format.date" ) );
+        return commonFormatting( date, FORMAT_DATE );
     }
 
     public String formatTime( Date date )
@@ -155,7 +159,7 @@
             return null;
         }
 
-        return commonFormatting( date, resourceBundle.getString( "format.time" ) );
+        return commonFormatting( date, FORMAT_TIME );
     }
 
     public String formatDateTime( Date date )
@@ -165,7 +169,7 @@
             return null;
         }
 
-        return commonFormatting( date, resourceBundle.getString( "format.datetime" ) );
+        return commonFormatting( date, FORMAT_DATETIME );
     }
 
     /**

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js	2012-03-06 03:17:52 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js	2012-03-07 10:32:33 +0000
@@ -69,9 +69,6 @@
             "required" : true,
             "rangelength" : [ 2, 25 ]
         },
-        "description" : {
-            "required" : true
-        },
         "code" : {
             "rangelength" : [ 0, 25 ],
             "alphanumericwithbasicpuncspaces" : true,
@@ -150,9 +147,6 @@
             "alphanumericwithbasicpuncspaces" : true,
             "rangelength" : [ 2, 25 ]
         },
-        "description" : {
-            "required" : true
-        },
         "code" : {
             "alphanumericwithbasicpuncspaces" : true,
             "notOnlyDigits" : false,

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm	2012-03-05 13:21:42 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/main.vm	2012-03-07 10:32:33 +0000
@@ -15,7 +15,7 @@
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 
     <script type="text/javascript">
-		var dateFormat = '$encoder.jsEscape($i18n.getString( 'format.date.label.jquery' ) , "'")';
+		var dateFormat = 'yy-mm-dd';
 	</script>
 
     <script type="text/javascript" src="../dhis-web-commons/javascripts/jQuery/jquery.min.js"></script>

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/popup.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/popup.vm	2011-10-06 15:53:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/popup.vm	2012-03-07 10:32:33 +0000
@@ -34,7 +34,7 @@
 	#end
 	
 	<script type="text/javascript">
-		var dateFormat = '$encoder.jsEscape($i18n.getString( 'format.date.label.jquery' ) , "'")';
+		var dateFormat = 'yy-mm-dd';
 	</script>  
   </head>
   

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm	2011-04-15 16:34:17 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/exportDataValueForm.vm	2012-03-07 10:32:33 +0000
@@ -92,9 +92,9 @@
 	<!-- Timespan -->
 	
 	<tr>
-		<th>$i18n.getString( "start_date" ) ($i18n.getString( "format.date.label" ))</th>
+		<th>$i18n.getString( "start_date" )</th>
 		<td></td>
-		<th>$i18n.getString( "end_date" ) ($i18n.getString( "format.date.label" ))</th>
+		<th>$i18n.getString( "end_date" )</th>
 	</tr>	
     <tr>
   		<td><input type="text" id="startDate" name="startDate" value="$!startDate" style="width:230px"></td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataArchiveForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataArchiveForm.vm	2011-03-28 15:28:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/dataArchiveForm.vm	2012-03-07 10:32:33 +0000
@@ -43,11 +43,11 @@
 <div id="contentDiv" style="display:none">
 <table width="100%">
     <tr>
-        <td style="width:170px">$i18n.getString( "start_date" ) ($i18n.getString( "format.date" ))</td>
+        <td style="width:170px">$i18n.getString( "start_date" )</td>
         <td><input type="text" id="startDate"/></td>
     </tr>
     <tr>
-        <td>$i18n.getString( "end_date" ) ($i18n.getString( "format.date" ))</td>
+        <td>$i18n.getString( "end_date" )</td>
         <td><input type="text" id="endDate"/></td>
     </tr>
     <tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/patientDataArchiveForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/patientDataArchiveForm.vm	2011-03-28 15:28:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataadmin/src/main/webapp/dhis-web-maintenance-dataadmin/patientDataArchiveForm.vm	2012-03-07 10:32:33 +0000
@@ -44,11 +44,11 @@
 <div id="contentDiv" style="display:none">
 <table width="100%">
     <tr>
-        <td style="width:170px">$i18n.getString( "start_date" ) ($i18n.getString( "format.date" ))</td>
+        <td style="width:170px">$i18n.getString( "start_date" )</td>
         <td><input type="text" id="startDate"/></td>
     </tr>
     <tr>
-        <td>$i18n.getString( "end_date" ) ($i18n.getString( "format.date" ))</td>
+        <td>$i18n.getString( "end_date" )</td>
         <td><input type="text" id="endDate"/></td>
     </tr>
     <tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm	2012-03-06 03:17:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/addDataSet.vm	2012-03-07 10:32:33 +0000
@@ -68,7 +68,7 @@
         <td><input type="text" id="shortName" name="shortName" style="width:20em"/></td>
       </tr>
       <tr>
-        <td><label>$i18n.getString( "description" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+        <td><label>$i18n.getString( "description" )</label></td>
         <td><input type="text" id="description" name="description" style="width:20em"/></td>
       </tr>
       <tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm	2012-03-06 03:17:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-dataset/src/main/webapp/dhis-web-maintenance-dataset/editDataSet.vm	2012-03-07 10:32:33 +0000
@@ -68,7 +68,7 @@
         <td><input type="text" id="shortName" name="shortName" style="width:20em" value="$!encoder.htmlEncode( $dataSet.shortName )"/></td>
       </tr>
       <tr>
-        <td><label>$i18n.getString( "description" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+        <td><label>$i18n.getString( "description" )</label></td>
         <td><input type="text" id="description" name="description" style="width:20em" value="$!encoder.htmlEncode( $dataSet.description )"/></td>
       </tr>
       <tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm	2012-03-06 03:17:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/addOrganisationUnitForm.vm	2012-03-07 10:32:33 +0000
@@ -38,7 +38,7 @@
 		<td><input type="text" id="shortName" name="shortName" style="width:20em"/></td>
 	</tr>
 	<tr>
-		<td><label for="description">$i18n.getString( "description" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+		<td><label for="description">$i18n.getString( "description" )</label></td>
 		<td><input type="text" id="description" name="description" style="width:20em"/></td>
 	</tr>
 	<tr>
@@ -46,7 +46,7 @@
 		<td><input type="text" id="code" name="code" style="width:20em"/></td>
 	</tr>
 	<tr>
-		<td><label for="openingDate">$i18n.getString( "opening_date" ) ($i18n.getString( "format.date.label" )) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+		<td><label for="openingDate">$i18n.getString( "opening_date" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 		<td><input type="text" id="openingDate" name="openingDate" value="$format.formatDate( $defaultDate )" style="width:20em"/></td>
 		<td></td>
 	</tr>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm	2012-03-06 03:17:52 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/updateOrganisationUnitForm.vm	2012-03-07 10:32:33 +0000
@@ -48,7 +48,7 @@
 		<td><input type="text" id="shortName" name="shortName" value="$encoder.htmlEncode( $organisationUnit.shortName )" style="width:20em"/></td>
 	</tr>
 	<tr>
-		<td><label for="description">$i18n.getString( "description" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+		<td><label for="description">$i18n.getString( "description" )</label></td>
 		<td><input type="text" id="description" name="description" value="$encoder.htmlEncode( $organisationUnit.description )" style="width:20em"/></td>
 	</tr>
 	<tr>
@@ -56,13 +56,13 @@
 		<td><input type="text" id="code" name="code" value="$!encoder.htmlEncode( $organisationUnit.code )" style="width:20em"/></td>
 	</tr>
 	<tr>
-		<td><label for="openingDate">$i18n.getString( "opening_date" ) ($i18n.getString( "format.date.label" )) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
+		<td><label for="openingDate">$i18n.getString( "opening_date" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 		<td><input type="text" id="openingDate" name="openingDate" value="$!format.formatDate( $organisationUnit.openingDate )" style="width:20em"/></td>
 		<td></td>
 	</tr>
 	#if( $numberOfChildren == 0 )
 	<tr>
-		<td><label for="closedDate">$i18n.getString( "closed_date" ) ($i18n.getString( "format.date.label" ))</label></td>
+		<td><label for="closedDate">$i18n.getString( "closed_date" )</label></td>
 		<td><input type="text" id="closedDate" name="closedDate" value="$!format.formatDate( $organisationUnit.closedDate )" style="width:20em"/></td>
 	</tr>
 	#end

=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewPivotTableForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewPivotTableForm.vm	2011-09-07 11:00:47 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/viewPivotTableForm.vm	2012-03-07 10:32:33 +0000
@@ -125,12 +125,12 @@
 </div>
 
 <div class="inputSection">
-<label>$i18n.getString( "start_date" ) ($i18n.getString( "format.date.label" ))</label><br>
+<label>$i18n.getString( "start_date" )</label><br>
 <input type="text" id="startDate" style="width:240px">
 </div>
 
 <div class="inputSection">
-<label>$i18n.getString( "end_date" ) ($i18n.getString( "format.date.label" ))</label><br>
+<label>$i18n.getString( "end_date" )</label><br>
 <input type="text" id="endDate" style="width:240px">
 </div>
 

=== modified file 'dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.vm'
--- dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.vm	2012-01-22 06:34:56 +0000
+++ dhis-2/dhis-web/dhis-web-validationrule/src/main/webapp/dhis-web-validationrule/runValidationForm.vm	2012-03-07 10:32:33 +0000
@@ -20,7 +20,7 @@
 <table>
     <tr>
     	<td>
-        	<label for="startDate">$i18n.getString( 'start_date' ) ($i18n.getString( "format.date.label" ))</label>
+        	<label for="startDate">$i18n.getString( 'start_date' )</label>
         </td>
         <td>
         	<input type="text" id="startDate" name="startDate" style="width:20em">        	
@@ -28,7 +28,7 @@
     </tr>
     <tr>    	
         <td>
-        	<label for="endDate">$i18n.getString( 'end_date' ) ($i18n.getString( "format.date.label" ))</label>
+        	<label for="endDate">$i18n.getString( 'end_date' )</label>
         </td>
         <td>
         	<input type="text" id="endDate" name="endDate" style="width:20em">