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

TypeScript chronoshift.WallTime类代码示例

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

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



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

示例1: formatStartEnd

export function formatStartEnd(start: Date, end: Date, timezone: Timezone): string {
  var startWallTime = WallTime.UTCToWallTime(start, timezone.toString());
  var endWallTime = WallTime.UTCToWallTime(end, timezone.toString());
  var endShiftWallTime = WallTime.UTCToWallTime(new Date(end.valueOf() - 1), timezone.toString());

  var formatted: string;
  if (startWallTime.getFullYear() !== endShiftWallTime.getFullYear()) {
    formatted = [formatWithYear(startWallTime), formatWithYear(endShiftWallTime)].join(JOIN);
  } else {
    if (startWallTime.getMonth() !== endShiftWallTime.getMonth() || startWallTime.getDate() !== endShiftWallTime.getDate()) {
      formatted = [formatWithoutYear(startWallTime), formatWithYear(endShiftWallTime)].join(JOIN);
    } else {
      formatted = formatWithYear(startWallTime);
    }
  }

  if (startWallTime.getHours() || endWallTime.getHours()) {
    var timeString: string;
    if (startWallTime.getHours() !== endShiftWallTime.getHours()) {
      timeString = [formatTimeOfDay(startWallTime), formatTimeOfDay(endShiftWallTime)].join(JOIN);
    } else {
      timeString = formatTimeOfDay(startWallTime);
    }
    formatted += ' ' + timeString.toLowerCase();
  }

  return formatted;
}
开发者ID:Ghostubborn,项目名称:pivot,代码行数:28,代码来源:date.ts


示例2: getWallTimeString

export function getWallTimeString(date: Date, timezone: Timezone, includeTime?: boolean, delimiter?: string): string {
  const wallTimeISOString = wallTimeHelper(WallTime.UTCToWallTime(date, timezone.toString())).toISOString();
  if (includeTime) {
    return wallTimeISOString.replace(/(\.\d\d\d)?Z?$/, '').replace('T', delimiter || ', ');
  }
  return wallTimeISOString.replace( /:\d\d(\.\d\d\d)?Z?$/, '').split('T')[0];
}
开发者ID:mdeora,项目名称:pivot,代码行数:7,代码来源:time.ts


示例3: require

  ], (require) => {
    var List = require('immutable').List;
    var WallTime = require('chronoshift').WallTime;
    var queryUrlExecutorFactory = require('./utils/ajax/ajax').queryUrlExecutorFactory;
    var DataSource = require('../common/models/index').DataSource;
    var PivotApplication = require('./components/pivot-application/pivot-application').PivotApplication;

    // Init chronoshift
    if (!WallTime.rules) {
      var tzData = require('chronoshift/lib/walltime/walltime-data.js');
      WallTime.init(tzData.rules, tzData.zones);
    }

    var dataSources = List(config.dataSources.map((dataSourceJS: DataSourceJS) => {
      var executor = queryUrlExecutorFactory(dataSourceJS.name, '/plywood', version);
      return DataSource.fromJS(dataSourceJS, { executor });
    }));

    ReactDOM.render(
      React.createElement(
        PivotApplication,
        {
          version,
          user: config.user,
          dataSources,
          linkViewConfig: config.linkViewConfig
        }
      ),
      container
    );
  }, 'pivot-main');
开发者ID:aakki,项目名称:pivot,代码行数:31,代码来源:pivot-entry.ts


示例4: formatTimeBasedOnGranularity

export function formatTimeBasedOnGranularity(range: TimeRange, granularity: Duration, timezone: Timezone, locale: Locale): string {
  const wallTimeStart = WallTime.UTCToWallTime(range.start, timezone.toString());

  const year = wallTimeStart.getFullYear();
  const month = wallTimeStart.getMonth();
  const day = wallTimeStart.getDate();
  const hour = wallTimeStart.getHours();
  const minute = wallTimeStart.getMinutes();
  const second = wallTimeStart.getSeconds();

  const monthString = locale.shortMonths[month];
  const hourToTwelve = hour % 12 === 0 ? 12 : hour % 12;
  const amPm = (hour / 12) >= 1 ? 'pm' : 'am';

  var granularityString = granularity.toJS();
  var unit = granularityString.substring(granularityString.length - 1);

  switch (unit) {
    case 'S':
      return `${monthString} ${day}, ${pad(hour)}:${pad(minute)}:${pad(second)}`;
    case 'M':
      var prefix = granularityString.substring(0, 2);
      return prefix === "PT" ? `${monthString} ${day}, ${hourToTwelve}:${pad(minute)}${amPm}` : `${monthString}, ${year}`;
    case 'H':
      return `${monthString} ${day}, ${year}, ${hourToTwelve}${amPm}`;
    case 'D':
      return `${monthString} ${day}, ${year}`;
    case 'W':
      return `${formatTimeRange(range, timezone, DisplayYear.ALWAYS)}`;
    default:
      return cleanISOString(wallTimeHelper(wallTimeStart).toISOString());
  }
}
开发者ID:avenger-teamave,项目名称:pivot,代码行数:33,代码来源:time.ts


示例5: require

  ], (require) => {
    var WallTime = require('chronoshift').WallTime;
    var queryUrlExecutorFactory = require('./utils/ajax/ajax').queryUrlExecutorFactory;
    var AppSettings = require('../common/models/index').AppSettings;
    var PivotApplication = require('./views/pivot-application/pivot-application').PivotApplication;

    var appSettings = AppSettings.fromJS(config.appSettings).attachExecutors((dataSource: DataSource) => {
      return queryUrlExecutorFactory(dataSource.name, 'plywood', version);
    });

    // Init chronoshift
    if (!WallTime.rules) {
      var tzData = require('chronoshift/lib/walltime/walltime-data.js');
      WallTime.init(tzData.rules, tzData.zones);
    }

    ReactDOM.render(
      React.createElement(
        PivotApplication,
        {
          version,
          user: config.user,
          appSettings,
          readOnly: config.readOnly
        }
      ),
      container
    );
  }, 'pivot-main');
开发者ID:boneill42,项目名称:pivot,代码行数:29,代码来源:pivot-entry.ts


示例6: require

  ], (require) => {
    const WallTime = require('chronoshift').WallTime;
    const queryUrlExecutorFactory = require('./utils/ajax/ajax').queryUrlExecutorFactory;
    const AppSettings = require('../common/models/index').AppSettings;
    const MANIFESTS = require('../common/manifests/index').MANIFESTS;
    const PivotApplication = require('./views/pivot-application/pivot-application').PivotApplication;

    var appSettings = AppSettings.fromJS(config.appSettings, {
      visualizations: MANIFESTS,
      executorFactory: (dataCube: DataCube) => {
        return queryUrlExecutorFactory(dataCube.name, 'plywood', version);
      }
    });

    // Init chronoshift
    if (!WallTime.rules) {
      var tzData = require('chronoshift/lib/walltime/walltime-data.js');
      WallTime.init(tzData.rules, tzData.zones);
    }

    ReactDOM.render(
      React.createElement(
        PivotApplication,
        {
          version,
          user: config.user,
          appSettings
        }
      ),
      container
    );
  }, 'pivot-main');
开发者ID:djfwan,项目名称:pivot,代码行数:32,代码来源:pivot-entry.ts


示例7: formatTimeRange

export function formatTimeRange(timeRange: TimeRange, timezone: Timezone, displayYear: DisplayYear): string {
  var { start, end } = timeRange;
  var startWallTime = WallTime.UTCToWallTime(start, timezone.toString());
  var endWallTime = WallTime.UTCToWallTime(end, timezone.toString());
  var endWallTimeInclusive = getEndWallTimeInclusive(end, timezone);

  var showingYear = true;
  var formatted: string;
  if (startWallTime.getFullYear() !== endWallTimeInclusive.getFullYear()) {
    formatted = [FORMAT_WITH_YEAR(startWallTime), FORMAT_WITH_YEAR(endWallTimeInclusive)].join(' - ');
  } else {
    showingYear = displayYear === DisplayYear.ALWAYS || (displayYear === DisplayYear.IF_DIFF && !isCurrentYear(endWallTimeInclusive.getFullYear(), timezone));
    var fmt = showingYear ? FORMAT_WITH_YEAR : FORMAT_WITHOUT_YEAR;
    if (startWallTime.getMonth() !== endWallTimeInclusive.getMonth() || startWallTime.getDate() !== endWallTimeInclusive.getDate()) {
      formatted = [FORMAT_WITHOUT_YEAR(startWallTime), fmt(endWallTimeInclusive)].join(' - ');
    } else {
      formatted = fmt(startWallTime);
    }
  }

  if (startWallTime.getHours() || startWallTime.getMinutes() || endWallTime.getHours() || endWallTime.getMinutes()) {
    formatted += (showingYear ? ' ' : ', ');

    var startTimeStr = formatTimeOfDay(startWallTime).toLowerCase();
    var endTimeStr = formatTimeOfDay(endWallTime).toLowerCase();

    if (startTimeStr === endTimeStr) {
      formatted += startTimeStr;
    } else {
      if (startTimeStr.substr(-2) === endTimeStr.substr(-2)) {
        startTimeStr = startTimeStr.substr(0, startTimeStr.length - 2);
      }
      formatted += [startTimeStr, endTimeStr].join('-');
    }
  }

  return formatted;
}
开发者ID:mdeora,项目名称:pivot,代码行数:38,代码来源:time.ts


示例8: monthToWeeks

export function monthToWeeks(firstDayOfMonth: Date, timezone: Timezone, locale: Locale): Date[][] {
  const weeks: Date[][] = [];
  const firstDayNextMonth = month.shift(firstDayOfMonth, timezone, 1);

  let week: Date[] = [];
  let currentPointer = day.floor(firstDayOfMonth, timezone);
  while (currentPointer < firstDayNextMonth) {
    var wallTime = WallTime.UTCToWallTime(currentPointer, timezone.toString());
    if ((wallTime.getDay() === locale.weekStart || 0) && week.length > 0) {
      weeks.push(week);
      week = [];
    }

    week.push(currentPointer);
    currentPointer = day.shift(currentPointer, timezone, 1);
  }
  // push last week
  if (week.length > 0) weeks.push(week);
  return weeks;
}
开发者ID:mdeora,项目名称:pivot,代码行数:20,代码来源:time.ts


示例9: getEndWallTimeInclusive

export function getEndWallTimeInclusive(exclusiveEnd: Date, timezone: Timezone) {
  return WallTime.UTCToWallTime(exclusiveToInclusiveEnd(exclusiveEnd), timezone.toString());
}
开发者ID:mdeora,项目名称:pivot,代码行数:3,代码来源:time.ts


示例10: isCurrentYear

function isCurrentYear(year: number, timezone: Timezone): boolean {
  var nowWallTime = WallTime.UTCToWallTime(new Date(), timezone.toString());
  return nowWallTime.getFullYear() === year;
}
开发者ID:mdeora,项目名称:pivot,代码行数:4,代码来源:time.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript chronoshift.day类代码示例发布时间:2022-05-24
下一篇:
TypeScript chronoshift.Timezone类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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