• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript DateFormatting.DateFormatting类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中app/utils/DateFormatting.DateFormatting的典型用法代码示例。如果您正苦于以下问题:TypeScript DateFormatting类的具体用法?TypeScript DateFormatting怎么用?TypeScript DateFormatting使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DateFormatting类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: selectDateInDatePicker

    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,代码行数:10,代码来源:DateFieldInputTest.ts


示例2: 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


示例3: runWithoutTheSecondArgument

 assert.throws(function runWithoutTheSecondArgument() {
   DateFormatting.parse('2015-06-07');
 },
开发者ID:gurdiga,项目名称:xo,代码行数:3,代码来源:DateFormattingTest.ts


示例4: runWithEmptyStringAsFirstArgument

 assert.throws(function runWithEmptyStringAsFirstArgument() {
   DateFormatting.parse('');
 },
开发者ID:gurdiga,项目名称:xo,代码行数:3,代码来源:DateFormattingTest.ts


示例5: runWithoutTheFirstArgument

 assert.throws(function runWithoutTheFirstArgument() {
   DateFormatting.parse();
 },
开发者ID:gurdiga,项目名称:xo,代码行数:3,代码来源:DateFormattingTest.ts


示例6: before

 before(function() {
   date = DateFormatting.parse('2015-06-07', 'YYYY-MM-DD');
 });
开发者ID:gurdiga,项目名称:xo,代码行数:3,代码来源:DateFormattingTest.ts


示例7: 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


示例8: 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



注:本文中的app/utils/DateFormatting.DateFormatting类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript delegateTo.delegateTo函数代码示例发布时间:2022-05-25
下一篇:
TypeScript createField.createField函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap