Просмотр исходного кода

Merge pull request #235 from crowi/fix-date-format

Fixed date format when create new memos
Sotaro KARASAWA 8 лет назад
Родитель
Сommit
e6d39cd901
1 измененных файлов с 5 добавлено и 3 удалено
  1. 5 3
      resource/js/crowi.js

+ 5 - 3
resource/js/crowi.js

@@ -215,8 +215,10 @@ $(function() {
   $('#create-page').on('shown.bs.modal', function (e) {
     // quick hack: replace from server side rendering "date" to client side "date"
     var today = new Date();
-    var dateString = today.getFullYear() + '/' + (today.getMonth() + 1) + '/' + today.getDate();
-    $('#create-page-today .page-today-suffix').text('/' + dateString);
+    var month = ('0' + (today.getMonth() + 1)).slice(-2);
+    var day = ('0' + today.getDate()).slice(-2);
+    var dateString = today.getFullYear() + '/' + month + '/' + day;
+    $('#create-page-today .page-today-suffix').text('/' + dateString + '/');
     $('#create-page-today .page-today-input2').data('prefix', '/' + dateString + '/');
 
     var input2Width = $('#create-page-today .col-xs-10').outerWidth();
@@ -224,7 +226,7 @@ $(function() {
       - $('#create-page-today .page-today-prefix').outerWidth()
       - $('#create-page-today .page-today-input1').outerWidth()
       - $('#create-page-today .page-today-suffix').outerWidth()
-      - 40
+      - 42
       ;
     $('#create-page-today .form-control.page-today-input2').css({width: newWidth}).focus();