Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用WallTime.js进行js时区转换,但出现错误_Javascript_Timezone_Commonjs_Walltime Js - Fatal编程技术网

Javascript 使用WallTime.js进行js时区转换,但出现错误

Javascript 使用WallTime.js进行js时区转换,但出现错误,javascript,timezone,commonjs,walltime-js,Javascript,Timezone,Commonjs,Walltime Js,我有一个客户在西海岸,但希望看到东海岸时间(美国/纽约)的信息 我正在尝试使用WallTime库: 当试图计算墙时间时,我得到以下错误: 未捕获错误:在设置时区之前必须使用规则和区域调用init当您在加载时区数据之前尝试初始化WallTime时,会发生这种情况。首先对require语句和/或require时区数据重新排序 资料来源:我是一名社交开发者。我认为你没有正确加载walltime data.js。您似乎正在使用RequireJS。您是否将walltime和walltime数据设置为模块?

我有一个客户在西海岸,但希望看到东海岸时间(美国/纽约)的信息

我正在尝试使用WallTime库:

当试图计算墙时间时,我得到以下错误:
未捕获错误:在设置时区之前必须使用规则和区域调用init

当您在加载时区数据之前尝试初始化WallTime时,会发生这种情况。首先对require语句和/或require时区数据重新排序


资料来源:我是一名社交开发者。

我认为你没有正确加载
walltime data.js
。您似乎正在使用RequireJS。您是否将
walltime
walltime数据
设置为模块?您是否将
walltime数据设置为
walltime
的依赖项?请参阅。@Matt Johnson:这些
require
是CommonJS模块,而不是
RequireJS
支持的AMD格式(此处比较:)
define(function(require) {

var _ = require('underscore'),
    Backbone = require('backbone'),
    WallTime = require('walltime');
require('backbone.relational');
require('walltime-data');


var DateRange = Backbone.RelationalModel.extend({
    initialize: function(opts) {

        var self = this,
            type = (opts && opts.type) || "today";

        if(type == "custom") {
            var undef = _.isUndefined(opts.start) && _.isUndefined(opts.end);

            if(undef)
                throw "'start' and/or 'end' date not present in options for type: custom";
        }

        function getNycDate(date){
            var someUTCDate = new Date(date.getTime()),
            nycWallTime = WallTime.UTCToWallTime(someUTCDate, "America/New_York");
            return nycWallTime;
        }

        function setup() {
            var now = getNycDate(new Date());
        }
     }
   }
}