當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript DateFormatting.format方法代碼示例

本文整理匯總了TypeScript中app/utils/DateFormatting.DateFormatting.format方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DateFormatting.format方法的具體用法?TypeScript DateFormatting.format怎麽用?TypeScript DateFormatting.format使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在app/utils/DateFormatting.DateFormatting的用法示例。


在下文中一共展示了DateFormatting.format方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: getDatePickerSelectedDate

    function getDatePickerSelectedDate() {
      var selectedDate = datePicker.querySelector('.is-selected .pika-day');
      assert(selectedDate, 'getDatePickerSelectedDate() expects a selected date in the date picker');

      var year =  selectedDate.getAttribute('data-pika-year');
      var month = selectedDate.getAttribute('data-pika-month');
      var day =   selectedDate.getAttribute('data-pika-day');

      return DateFormatting.format(new Date(year, month, day), DateFieldInput.DATE_FORMAT);
    }
開發者ID:gurdiga,項目名稱:xo,代碼行數:10,代碼來源:DateFieldInputTest.ts

示例2: runWithoutTheSecondArgument

 assert.throws(function runWithoutTheSecondArgument() {
   DateFormatting.format(date);
 },
開發者ID:gurdiga,項目名稱:xo,代碼行數:3,代碼來源:DateFormattingTest.ts

示例3: runWithoutTheFirstArgument

 assert.throws(function runWithoutTheFirstArgument() {
   DateFormatting.format();
 },
開發者ID:gurdiga,項目名稱:xo,代碼行數:3,代碼來源:DateFormattingTest.ts

示例4: before

 before(function() {
   date = new Date(2015, 10, 7);
   formattedDate = DateFormatting.format(date, 'DD/MM/YYYY');
 });
開發者ID:gurdiga,項目名稱:xo,代碼行數:4,代碼來源:DateFormattingTest.ts

示例5: it

  it('works', function(done) {
    assert.equal(datePickerButton.title, 'Deschide calendarul', 'has the appropriate tool-tip');

    var datePicker = getDatePicker();
    assert.isNull(datePicker, 'date picker is not there before clicking the button');

    datePickerButton.click();
    assert.isNotTrue(bodyClickListener.executed, 'clicks do not propagate to <body>, and don’t hide the picker');

    datePicker = getDatePicker();
    assert.isTrue(datePicker.classList.contains('xo'), 'has the “xo” theme');

    var firstMonth = datePicker.querySelector('.pika-select-month option');
    assert.equal(firstMonth.textContent, 'Ianuarie', 'month names are translated');

    var firstWeekDay = datePicker.querySelector('.pika-table th abbr');
    assert.equal(firstWeekDay.title, 'Luni', 'first day of the wiik is Monday');
    assert.equal(firstWeekDay.textContent, 'Lu', 'short week day names are translated');

    var prevMonthButton = datePicker.querySelector('button.pika-prev');
    assert.equal(prevMonthButton.textContent, 'luna precedentă', 'the button to go to previous month is translated');

    var nextMonthButton = datePicker.querySelector('button.pika-next');
    assert.equal(nextMonthButton.textContent, 'luna următoare', 'the button to go to next month is translated');

    assert.equal(getDatePickerSelectedDate(), domElement.value, 'when opened, date picker reflects input’s value');

    var newDate = nextDay(domElement.value);
    selectDateInDatePicker(newDate);
    assert.equal(getDatePickerSelectedDate(), newDate, 'when selected, it updates input value accordingly');
    assert.equal(dateFieldInput.getValue(), newDate, 'when selected, getValue() returns the new value');

    datePicker = getDatePicker();
    assert.isNull(datePicker, 'hides the date picker when a date is selected');

    domElement.value = '';
    datePickerButton.click();
    datePicker = getDatePicker();
    assert.isNotNull(datePicker, 'date picker is displayed with en empty field value');

    var todayDate = DateFormatting.format(new Date(), DateFieldInput.DATE_FORMAT);
    assert.equal(getDatePickerSelectedDate(), todayDate,
      'when opening the date picker with an empty field, it has today marked');

    datePickerButton.click();
    datePicker = getDatePicker();
    assert.isNull(datePicker, 'hides the date picker when clicked again');

    /* this setTimeout call is required because focus() is called async too */
    window.setTimeout(function() {
      assert.equal(document.activeElement, domElement, 'when the date picker is closed, the input get focus again');

      datePickerButton.click();
      document.body.click();
      datePicker = getDatePicker();
      assert.isNull(datePicker, 'hides the date picker when clicking outside');

      datePickerButton.click();
      simulateEscapeKey();
      datePicker = getDatePicker();
      assert.isNull(datePicker, 'hides the date picker when pressing Escape key');

      done();
    });

    function getDatePicker() {
      return sandbox.querySelector(DateFieldInput.DATE_PICKER_SELECTOR);
    }

    function getDatePickerSelectedDate() {
      var selectedDate = datePicker.querySelector('.is-selected .pika-day');
      assert(selectedDate, 'getDatePickerSelectedDate() expects a selected date in the date picker');

      var year =  selectedDate.getAttribute('data-pika-year');
      var month = selectedDate.getAttribute('data-pika-month');
      var day =   selectedDate.getAttribute('data-pika-day');

      return DateFormatting.format(new Date(year, month, day), DateFieldInput.DATE_FORMAT);
    }

    function nextDay(initialFormattedDate) {
      var initialDate = DateFormatting.parse(initialFormattedDate, DateFieldInput.DATE_FORMAT);
      var nextDate = new Date(initialDate.getFullYear(), initialDate.getMonth(), initialDate.getDate() + 1);

      return DateFormatting.format(nextDate, DateFieldInput.DATE_FORMAT);
    }

    function selectDateInDatePicker(newDate) {
      var date = DateFormatting.parse(newDate, DateFieldInput.DATE_FORMAT);
      var selectorForDate = '.pika-day' +
        '[data-pika-year="' + date.getFullYear() + '"]' +
        '[data-pika-month="' + date.getMonth() + '"]' +
        '[data-pika-day="' + date.getDate() + '"]';

      var correspondingDate = datePicker.querySelector(selectorForDate);
      correspondingDate.dispatchEvent(new Event('mousedown'));
    }
  });
開發者ID:gurdiga,項目名稱:xo,代碼行數:98,代碼來源:DateFieldInputTest.ts

示例6: nextDay

    function nextDay(initialFormattedDate) {
      var initialDate = DateFormatting.parse(initialFormattedDate, DateFieldInput.DATE_FORMAT);
      var nextDate = new Date(initialDate.getFullYear(), initialDate.getMonth(), initialDate.getDate() + 1);

      return DateFormatting.format(nextDate, DateFieldInput.DATE_FORMAT);
    }
開發者ID:gurdiga,項目名稱:xo,代碼行數:6,代碼來源:DateFieldInputTest.ts

示例7: function

 this.setDate = function(date) {
   var formattedDate = DateFormatting.format(date, DateFieldInput.DATE_FORMAT);
   input.setValue(formattedDate);
 };
開發者ID:gurdiga,項目名稱:xo,代碼行數:4,代碼來源:DateFieldInput.ts


注:本文中的app/utils/DateFormatting.DateFormatting.format方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。