Exemple #1
0
var addDate = function(event, date, time, am) {
    var d = date.split(/[\s,]+/);
    var day = d[1];
    if (day.length < 2) day = '0' + day;
    var t2 = time.split(':');
    var hour = t2[0];
    var minutes = t2[1];
    // 0 pad
    if (hour.length < 2) hour = '0' + hour;
    // mod 12 now, add 12 for PM later
    if (hour == '12') hour = '00';
    var ds = d[2] + '-' + months[d[0]] + '-' + day + ' ' + hour + ':' + minutes;
    //console.log('  date string: ' + ds);
    var date24 = us(ds,'America/New_York');
    // Convert to 24 hour clock
    if (!am)
        date24 = tz(date24, '+12 hours');
    var endDate = tz(date24, '+1 hours');
    // If the end time is before the beginning, assume it is next day
    // e.g. start 11:00 PM, end 12:00 AM
    var startString = tz(date24, '%FT%T%^z');
    var endString = tz(endDate, '%FT%T%^z');
    event.start = {dateTime: startString};
    event.end = {dateTime: endString};
};
Exemple #2
0
function prove (assert) {
    var tz = require('timezone'), util = require('../util')
    assert(tz(util.bicentennial, '%D'), '07/04/76', 'short date format')
    assert(tz(util.bicentennial, '%x'), '07/04/1976', 'long date format')
    assert(tz(util.moonwalk, '%r'), '02:56:00 AM', 'meridiem time format')
    assert(tz(util.moonwalk, '%R'), '02:56', 'military time format')
    assert(tz(util.moonwalk, '%T'), '02:56:00', 'military time format with seconds')
}
Exemple #3
0
    var handleResponse = function(err, result) {
        var speech = "I'm sorry, there was an error looking up data from the ISS API.";
        console.log("lookup done: " + JSON.stringify(result));
        if (err) {            
            console.log("There was an error " + err);
            callback(speech);
        } else {
            // Find Time Zone
            var timezone = tzlookup(latitude, longitude);
            console.log("Testing library " + tzlookup(latitude, longitude));
            // Convert UTC seconds to M:D:Y, H:M:S format
            var isstime = result.response[0].risetime*1000;
            var passtime = new Date(isstime);
            console.log("ISS API passtime UTC " + isstime);
            var convertUTC = tz(passtime);
            var realtime = new Date(convertUTC);
            var currenttime = moment(realtime).tz(timezone).format('MMMM Do YYYY, h:mm:ss a');
            console.log("Time zone convert " + convertUTC + " Correct Time zone is " + currenttime);
            console.log("iss query succeeded. " + currenttime);
            // voice response
            var info = "The ISS will pass over " + currenttime + "."

            callback(info);
        }
    }};
Exemple #4
0
Lottery._sortTime = function (timeStr) {
	var lotterytz = tz(require("timezone/" + this.timeZone));
	var lotteryDate= tz(new Date().getTime(), "%F ", this.timeZone);//拿到当前时区的日期
	switch (timeStr.split(":").length)
	{
		case 1 ://只有秒数 拿到的是下一期剩余读秒数 所以要减去一期时间
			//console.log(timeStr + "seconds left");
			//console.log(new Date());
			//console.log(new Date(new Date().getTime() + parseInt(timeStr) * 1000));
			return Math.floor(new Date().getTime() / 1000 + parseInt(timeStr) - this.drawSeconds);
		case 2 :
		case 3 ://时间格式完全
			var time = lotterytz(new Date(Date.parse(lotteryDate + timeStr)).Format("yyyy-MM-dd hh:mm:ss"), this.timeZone);//算出当地游戏开奖时间
			
			
            /* 
             * 现在我们算出开奖时间和现在的时间差
             * 由于网站公布的数据有可能是23;xx到00:xx的结果
             * 严格来讲 应该是没有比现在还要晚一期的时间的,
			 * 但是实际使用中,由于机器时间误差,可能是多晚一些,这里所以时间可以是晚两局时间
			 * 也就是 drawSeconds * 2
             */
			if ((time - new Date().getTime()) > this.drawSeconds * 2 * 1000)
			{
				time = time - 60 * 60 * 24 * 1000;//那么时间就是昨天的,天数减去1
			}

			//处理加拿大西部时间
			if (this.id == 7)
			{
				var delaySecond = 30;//延迟n秒确定开奖 
			}

			return Math.floor(time / 1000);
		default:
			break;
	
	}
	


}
Exemple #5
0
  function dateTransformer (jsonStr, enc, callback) {

    var data = JSON.parse(jsonStr);

    if(convertTimestamp){
      data.x = tz(data.x+startTime, timezone, timezoneObj, "%m-%d-%Y %H:%M:%S.%N"); //http://bigeasy.github.io/timezone/#section-70
    }

    this.push(JSON.stringify(data)+"\n");

    callback();

  }
Exemple #6
0
exports.ferry_time_to_tz = function(ferry_time, now) {
  var time = ferry_time.split(' ')[0];
  var ampm = ferry_time.split(' ')[1];

  var hour =     time.split(':')[0];
  if (ampm == 'PM') {hour = parseInt(hour)+12; hour = String(hour);}

  hour = pad_digits(hour);
  var minutes =  time.split(':')[1];
  var now = now || tz(new Date());
  var time_in = us(now, 'America/Los_Angeles', '%Y-%m-%d') + " " + hour + ":" + minutes + ":00";

  return us(time_in, 'America/Los_Angeles', '%c');
};
Exemple #7
0
function generate (inputs) {

  var treatments = find_meals(inputs);

  var opts = {
    treatments: treatments
  , profile: inputs.profile
  };

  var clock = new Date(tz(inputs.clock));

  var meal_data = sum(opts, clock);
  return meal_data;
}
rl.getByProcess(2546547879211, function(err, data){
    
    if(err && err != null) return;
    
    var obj = data[0];
    
    // var tz = require("timezone");
    // var br = tz(require("timezone/Brazil"));
    // var f = br(obj.date, "%d/%m/%Y %H:%M:%S", "Brazil/East");
    
    var tz = require("timezone");
    var f = tz(obj.date, "%d/%m/%Y %H:%M:%S", "Brazil/East", require("timezone/Brazil"));

    console.log(f);
});
Exemple #9
0
function prove (assert) {
    var tz = require('timezone'), util = require('../util')
    var detroit = tz(require('timezone/America/Detroit'), 'America/Detroit')
    assert(tz(detroit('1945-09-30 01:59:00'), '%F %T'), '1945-09-30 05:59:00', 'to UTC before peace time')
    assert(tz(detroit('1945-09-30 02:00:00'), '%F %T'), '1945-09-30 07:00:00', 'to UTC before peace time')

    assert(detroit(tz('1945-09-30 06:00:00'), '-1 millisecond', '%z'), '-0400', 'from UTC before start of cold war')
    assert(detroit(tz('1945-09-30 06:00:00'), '%z'), '-0500', 'from UTC at start of cold war')
    assert(detroit(tz('1945-09-30 06:00:00'), '+1 millisecond', '%z'), '-0500', 'from UTC after start of cold war')
}
Exemple #10
0
function prove (assert) {
    var tz = require('timezone')
    var detroit = tz(require('timezone/America/Detroit'), 'America/Detroit')
    assert(detroit('1975-04-27 02:59:00'), null, 'missing time')
    assert(tz(detroit('1975-04-27 01:59:00'), '%c'), 'Sun 27 Apr 1975 06:59:00 AM UTC', 'start late to UTC')
    assert(tz(detroit('1975-04-27 03:00:00'), '%c'), 'Sun 27 Apr 1975 07:00:00 AM UTC', 'start late to UTC')

    assert(detroit(tz('1975-04-27T07:00:00'), '-1 millisecond', '%z'), '-0500', 'before start late')
    assert(detroit(tz('1975-04-27T07:00:00'), '%z'), '-0400', 'start late')
    assert(detroit(tz('1975-04-27T07:00:00'), '+1 millisecond', '%z'), '-0400', 'after start late')
}
Exemple #11
0
function generate (inputs) {

  var treatments = find_meals(inputs);

  var opts = {
    treatments: treatments
  , profile: inputs.profile
  , pumphistory: inputs.history
  , glucose: inputs.glucose
  , basalprofile: inputs.basalprofile
  };

  var clock = new Date(tz(inputs.clock));

  var meal_data = sum(opts, clock);
  return meal_data;
}
Exemple #12
0
 treatments.forEach(function(treatment) {
     now = time.getTime();
     var dia_ago = now - profile_data.dia*60*60*1000;
     t = new Date(tz(treatment.timestamp)).getTime();
     if(t > dia_ago && t <= now) {
         if (treatment.carbs >= 1) {
             if (t < firstCarbTime) {
                 //firstCarbTime = treatment.timestamp;
                 firstCarbTime = t;
                 //console.error(firstCarbTime);
             }
             carbs += parseFloat(treatment.carbs);
         }
         if (treatment.bolus >= 0.1) {
             boluses += parseFloat(treatment.bolus);
         }
     }
 });
Exemple #13
0
function prove (assert) {
    var tz = require('timezone'), util = require('../util')
    assert(tz(util.y2k, '%N'), '000000000', 'top of hour')
    assert(tz(util.utc(1980, 0, 1, 0, 0, 1, 999), '%N'), '999000000', 'last millisecond')
    assert(tz(util.utc(1980, 0, 1, 0, 0, 1, 3), '%N'), '003000000', 'nanoseconds')
}
Exemple #14
0
var AlexaSkill = require('./AlexaSkill');



var ISStracker = function () {
    AlexaSkill.call(this, APP_ID);
};
var AWS = require("aws-sdk");
AWS.config.update({region: "us-east-1"});
var doc = require("dynamodb-doc");

var ok = require("assert")
    , eq = require("assert").equal
    , tz = require("timezone");
var us = tz(require("timezone/America"));
var tzlookup = require("tz-lookup");
var moment = require("moment-timezone");
var request = require("request");
var dynamodb = new AWS.DynamoDB.DocumentClient();
ISStracker.prototype = Object.create(AlexaSkill.prototype);
ISStracker.prototype.constructor = ISStracker;

ISStracker.prototype.eventHandlers.onSessionStarted = function (sessionStartedRequest, session) {
    console.log("ISStracker onSessionStarted requestId: " +
                sessionStartedRequest.requestId +
                ", sessionId: " +
                session.sessionId);
};

ISStracker.prototype.eventHandlers.onLaunch = function (launchRequest, session, response) {
Exemple #15
0
function calcTempTreatments (inputs) {
  var pumpHistory = inputs.history;
  var profile_data = inputs.profile;
    var tempHistory = [];
    var tempBoluses = [];
    var now = new Date();
    var timeZone = now.toString().match(/([-\+][0-9]+)\s/)[1];

    // Pick relevant events for processing and clean the data

    for (var i=0; i < pumpHistory.length; i++) {
        var current = pumpHistory[i];
        //if(pumpHistory[i].date < time) {
            if (current.bolus && current.bolus._type == "Bolus") {
                var temp = current;
                current = temp.bolus;
            }
            if (current._type == "Bolus") {
                var temp = {};
                temp.timestamp = current.timestamp;
                temp.started_at = new Date(tz(current.timestamp));
                temp.date = temp.started_at.getTime();
                temp.insulin = current.amount;
                tempBoluses.push(temp);
            } else if (current.eventType == "Temp Basal") {
                var temp = {};
                temp.rate = current.rate;
                temp.duration = current.duration;
                temp.timestamp = current.timestamp;
                temp.started_at = new Date(tz(temp.timestamp));
                temp.date = temp.started_at.getTime();
                temp.duration = current.duration;
                tempHistory.push(temp);
            } else if (current._type == "TempBasal") {
                if (current.temp == 'percent') {
                    continue;
                }
                var rate = current.rate;
                var date = current.date;
                if (i>0 && pumpHistory[i-1].date == date && pumpHistory[i-1]._type == "TempBasalDuration") {
                    var duration = pumpHistory[i-1]['duration (min)'];
                } else if (i+1<pumpHistory.length && pumpHistory[i+1].date == date && pumpHistory[i+1]._type == "TempBasalDuration") {
                    var duration = pumpHistory[i+1]['duration (min)'];
                } else { console.error("No duration found for "+rate+" U/hr basal"+date, pumpHistory[i - 1], current, pumpHistory[i + 1]); }
                var temp = {};
                temp.rate = rate;
                temp.timestamp = current.timestamp;
                temp.started_at = new Date(tz(temp.timestamp));
                temp.date = temp.started_at.getTime();
                temp.duration = duration;
                tempHistory.push(temp);
            }
        //}
    }

    // Check for overlapping events and adjust event lengths in case of overlap

    tempHistory = _.sortBy(tempHistory, 'date');

    for (var i=0; i+1 < tempHistory.length; i++) {
        if (tempHistory[i].date + tempHistory[i].duration*60*1000 > tempHistory[i+1].date) {
            tempHistory[i].duration = (tempHistory[i+1].date - tempHistory[i].date)/60/1000;
        }
    }

    // Create an array of moments to slit the temps by
    // currently supports basal changes
    // TODO: add pump suspends

    var splitterEvents = [];

    _.forEach(profile_data.basalprofile,function addSplitter(o) {
        var splitterEvent = {};
        splitterEvent.type = 'recurring';
        splitterEvent.minutes = o.minutes;
        splitterEvents.push(splitterEvent);
    });

    // iterate through the events and split if needed

    var splitHistory = [];

    _.forEach(tempHistory, function splitEvent(o) {
        splitHistory = splitHistory.concat(splitTimespan(o,splitterEvents));
    });

    tempHistory = _.sortBy(tempHistory, function(o) { return o.date; });
    splitHistory = _.sortBy(splitHistory, function(o) { return o.date; });

    tempHistory = splitHistory;

    // iterate through the temp basals and create bolus events from temps that affect IOB

    var tempBolusSize;

    for (var i=0; i < tempHistory.length; i++) {

        var currentItem = tempHistory[i];

        if (currentItem.duration > 0) {

            var currentRate = profile_data.current_basal;

            if (!_.isEmpty(profile_data.basalprofile)) {
                currentRate = basalprofile.basalLookup(profile_data.basalprofile,new Date(currentItem.timestamp));
            }

            var netBasalRate = currentItem.rate - currentRate;
            if (netBasalRate < 0) { tempBolusSize = -0.05; }
            else { tempBolusSize = 0.05; }
            var netBasalAmount = Math.round(netBasalRate*currentItem.duration*10/6)/100
            var tempBolusCount = Math.round(netBasalAmount / tempBolusSize);
            var tempBolusSpacing = currentItem.duration / tempBolusCount;
            for (var j=0; j < tempBolusCount; j++) {
                var tempBolus = {};
                tempBolus.insulin = tempBolusSize;
                tempBolus.date = currentItem.date + j * tempBolusSpacing*60*1000;
                tempBolus.created_at = new Date(tempBolus.date);
                tempBoluses.push(tempBolus);
            }
        }
    }
    var all_data =  [ ].concat(tempBoluses).concat(tempHistory);
    all_data = _.sortBy(all_data, 'date');
    return all_data;
}
Exemple #16
0
var fs = require("fs"),tz = require("timezone");
eval(fs.readFileSync('./library/dateformat.js').toString());
var url = "http://www.wclc.com/app/winning_numbers/keno.html?monthYear=" + tz(require("timezone/" + "Canada/Pacific"))(new Date().getTime(), "%d-%b-%Y ", "Canada/Pacific");

console.log(url);
canada = tz(require("timezone/" + "Canada/Pacific"));
var canadaNowHour = parseInt(canada(new Date().getTime(), "%-I", "Canada/Pacific"));
var firstTime;
if (canadaNowHour >=4){
	firstTime = canada(new Date().getTime(), "%F 04:30:00", "Canada/Pacific");
}else{
	firstTime = canada(new Date().getTime() - 60*60*24*1000, "%F 04:30:00", "Canada/Pacific");
}
var pastDraw = Math.floor((new Date().getTime() - canada(firstTime)) / 1000 / 300);
console.log(pastDraw);

console.log(canada(new Date().getTime(), "%F %T", "Canada/Pacific"));
console.log(canadaNowHour);
console.log(firstTime);

/*

                    ulong maxRound  = Convert.ToUInt64(GetMaxRound(rounds));//最后的期数
                    ulong minRound  = Convert.ToUInt64(GetMinRound(rounds));//最后的期数
                    ulong thisRound = Convert.ToUInt64(round);//当期期数
	

	
var url = "http://www.wclc.com/app/winning_numbers/keno.html?monthYear=" + TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time")).ToString("dd-MMM-yyyy", System.Globalization.CultureInfo.InvariantCulture)";
var delaySecond = 30;//延迟n秒确定开奖 
*/
Exemple #17
0
 hbs.handlebars.registerHelper('dateFormat', function(context) {
     var date = tz(context,"%m/%d/%Y");
     return date;
 });
Exemple #18
0
function prove (assert) {
    var tz = require('timezone'), util = require('../util')
    tz = tz(require('timezone/America/Detroit'), 'America/Detroit')
    assert(tz(util.utc(1980, 0, 1), 'America/Detroit', '%F %T'), '1979-12-31 19:00:00', 'convert from UTC to wallclock')
}
Exemple #19
0
function prove (assert) {
    var tz = require('timezone')
    tz = tz(require('timezone/America/Detroit'))
    // Across dst transitions.
    assert(tz('2010-03-14 12:00', 'America/Detroit', '-24 hour', '%c'), 'Sat 13 Mar 2010 11:00:00 AM EST',
         'subtract hours across spring forward')
    assert(tz('2010-03-14 03:00', 'America/Detroit', '-1 minute', '%c'), 'Sun 14 Mar 2010 01:59:00 AM EST',
         'subtract minute across spring forward')
    assert(tz('2010-11-07 03:00', 'America/Detroit', '-61 minute', '%c'), 'Sun 07 Nov 2010 01:59:00 AM EST',
         'subtract to minute before hour after fall back')
    assert(tz('2010-11-07 03:00', 'America/Detroit', '-121 minutes', '%c'), 'Sun 07 Nov 2010 01:59:00 AM EDT',
         'subtract to minute before fall back')
    assert(tz('2010-11-07 02:00', 'America/Detroit', '-2 hours', '%c'), 'Sun 07 Nov 2010 01:00:00 AM EDT',
         'substract to an hour before fall back')

    // Minute by minute within the time zone
    assert(tz('2010-11-07 02:00', 'America/Detroit', '-30 minutes', '%c'), 'Sun 07 Nov 2010 01:30:00 AM EST',
         '-30 minutes from hour after fall back')
    assert(tz('2010-11-07 02:00', 'America/Detroit', '-60 minutes', '%c'), 'Sun 07 Nov 2010 01:00:00 AM EST',
         '-60 minutes from hour after fall back')
    assert(tz('2010-11-07 02:00', 'America/Detroit', '-90 minutes', '%c'), 'Sun 07 Nov 2010 01:30:00 AM EDT',
         '-90 minutes from hour after fall back')
    assert(tz('2010-11-07 02:00', 'America/Detroit', '-120 minutes', '%c'), 'Sun 07 Nov 2010 01:00:00 AM EDT',
        '-120 minutes from hour after fall back')

    // Landing on missing times.
    assert(tz('2010-03-13 02:30', 'America/Detroit', '+1 day', '%c'), 'Sun 14 Mar 2010 01:30:00 AM EST',
         'add day lands on missing dst start time')
    assert(tz('2010-03-13 03:30', 'America/Detroit', '+1 day', '%c'), 'Sun 14 Mar 2010 03:30:00 AM EDT',
         'add day lands after missing dst start time')
    assert(tz('2010-03-15 02:30', 'America/Detroit', '-1 day', '%c'), 'Sun 14 Mar 2010 03:30:00 AM EDT',
         'subtract day to missing dst start time')
    assert(tz('2010-03-15 03:30', 'America/Detroit', '-1 day', '%c'), 'Sun 14 Mar 2010 03:30:00 AM EDT',
         'subtract day to hour after missing dst start time')
}
Exemple #20
0
var tz = require('timezone');
var us = tz(require('timezone/America'));

var cardinal_directions = ['N','NNE','NE','ENE','E','ESE','SE','SSE','S','SSW','SW','WSW','W','WNW','NW','NNW'];

/*
Input: a wind direction in degrees, like 180, 265, or 50
Ouput: a cardinal wind direction., like 'S', 'WSW', or 'NW'
*/
exports.degrees_to_cardinal = function(degrees) {
  degrees = parseInt(degrees);
  return cardinal_directions[Math.floor(((degrees+11.25) % 360) / 22.5 )];
};

/* Convert degrees to radians. */
var deg_to_rad = function(deg) {
  return deg * Math.PI / 180;
};

/* Convert radians to degrees */
var rad_to_deg = function(rad) {
  return rad * 180 / Math.PI;
};


/* Get u component of wind speed and direction. */
var calc_u = function(speed, direction) {
  return Math.sin(deg_to_rad(direction + 180)) * speed;
};

/* Get u component of wind speed and direction. */
Exemple #21
0
function prove (equal) {
    var tz = require('timezone'), util = require('../util')
    var rfc822 = require("timezone/rfc822")
    equal(tz(rfc822("Sat, 13 Aug 2011 10:24:20 -0400"), "%c"), tz(Date.UTC(2011, 7, 13, 14, 24, 20), "%c"), "rfc822")
    equal(tz(rfc822("Sat, 13 Aug 2011 10:24:20 -0000"), "%c"), tz(Date.UTC(2011, 7, 13, 10, 24, 20), "%c"), "rfc822")
    try {
        rfc822("Z")
    } catch (e) {
        equal(e.message, "invalid rfc822 date", "non-sense date")
    }
    try {
        rfc822("Mon, 13 Aug 2011 10:24:20 -0000")
    } catch (e) {
        equal(e.message, "incorrect day of week for date", "day does not match")
    }
    equal(tz(rfc822("Sat, 13 Aug 2011 10:24:20 EDT"), "%c"), tz(Date.UTC(2011, 7, 13, 14, 24, 20), "%c"), "abbrev")
    equal(tz(rfc822("Thu, 13 Aug 09 10:24:20 -0400"), "%c"), tz(Date.UTC(2009, 7, 13, 14, 24, 20), "%c"), "two digit year less than 50")
    equal(tz(rfc822("Sat, 13 Aug 88 10:24:20 -0400"), "%c"), tz(Date.UTC(1988, 7, 13, 14, 24, 20), "%c"), "two digit year greater than 50")
    equal(tz(rfc822("Sat, 13 Aug 111 10:24:20 -0400"), "%c"), tz(Date.UTC(2011, 7, 13, 14, 24, 20), "%c"), "three digit year")

    equal(tz(rfc822("Sun, 1 Mar (Spring is coming soon!) 92 00:00:00 GMT")), tz("1992-03-01"), "comments")

    // The example from the RFC 822 docco.

    var military = { nato: {}, rfc822: {} }
      , index
    // , tz = require("timezone")
      , moonwalk = tz("1969-07-21 02:56")
   //  , eq = require("assert").equal

    index = 0
    "ABCDEFGHIKLM".replace(/./g, function (ch) {
        var offset = ("0" + (++index) + "00").slice(-4)
        military.nato[ch] = "+" + offset
        military.rfc822[ch] = "-" + offset
    })

    index = 0
    "NOPQRSTUVWXY".replace(/./g, function (ch) {
        var offset = ("0" + (++index) + "00").slice(-4)
        military.nato[ch] = "-" + offset
        military.rfc822[ch] = "+" + offset
    })

    equal(tz(rfc822("Sun, 20 Jul 1969 21:56:00 E", military.rfc822)), moonwalk, "RFC 822 military")
    equal(tz(rfc822("Sun, 20 Jul 1969 21:56:00 R", military.nato)), moonwalk, "NATO")
}
Exemple #22
0
function prove (assert) {
    var tz = require('timezone'), util = require('../util')
    // Month digits.
    assert(tz(util.moonwalk, '%m'), '07', 'two digit july')
    assert(tz(util.y2k, '%m'), '01', 'two digit january')

    // Abbreviated month.
    assert(tz(util.moonwalk, '%h'), 'Jul', 'abbreviation')
    assert(tz(util.moonwalk, '%b'), 'Jul', 'locale abbreviation')
    assert(tz(util.utc(1980, 0, 1), '%b'), 'Jan', 'locale abbreviation January')
    assert(tz(util.utc(1980, 1, 1), '%b'), 'Feb', 'locale abbreviation February')
    assert(tz(util.utc(1980, 2, 1), '%b'), 'Mar', 'locale abbreviation March')
    assert(tz(util.utc(1980, 3, 1), '%b'), 'Apr', 'locale abbreviation April')
    assert(tz(util.utc(1980, 4, 1), '%b'), 'May', 'locale abbreviation May')
    assert(tz(util.utc(1980, 5, 1), '%b'), 'Jun', 'locale abbreviation June')
    assert(tz(util.utc(1980, 6, 1), '%b'), 'Jul', 'locale abbreviation July')
    assert(tz(util.utc(1980, 7, 1), '%b'), 'Aug', 'locale abbreviation August')
    assert(tz(util.utc(1980, 8, 1), '%b'), 'Sep', 'locale abbreviation September')
    assert(tz(util.utc(1980, 9, 1), '%b'), 'Oct', 'locale abbreviation October')
    assert(tz(util.utc(1980, 10, 1), '%b'), 'Nov', 'locale abbreviation November')
    assert(tz(util.utc(1980, 11, 1), '%b'), 'Dec', 'locale abbreviation December')

    // Full month.
    assert(tz(util.moonwalk, '%B'), 'July', 'locale full')
    assert(tz(util.utc(1980, 0, 1), '%B'), 'January', 'locale full January')
    assert(tz(util.utc(1980, 1, 1), '%B'), 'February', 'locale full February')
    assert(tz(util.utc(1980, 2, 1), '%B'), 'March', 'locale full March')
    assert(tz(util.utc(1980, 3, 1), '%B'), 'April', 'locale full April')
    assert(tz(util.utc(1980, 4, 1), '%B'), 'May', 'locale full May')
    assert(tz(util.utc(1980, 5, 1), '%B'), 'June', 'locale full June')
    assert(tz(util.utc(1980, 6, 1), '%B'), 'July', 'locale full July')
    assert(tz(util.utc(1980, 7, 1), '%B'), 'August', 'locale full August')
    assert(tz(util.utc(1980, 8, 1), '%B'), 'September', 'locale full September')
    assert(tz(util.utc(1980, 9, 1), '%B'), 'October', 'locale full October')
    assert(tz(util.utc(1980, 10, 1), '%B'), 'November', 'locale full November')
    assert(tz(util.utc(1980, 11, 1), '%B'), 'December', 'locale full December')
}
Exemple #23
0
function prove (equal) {
    var tz = require('timezone')
    equal(tz(7), 7, "integer")
    equal(tz(new Date(7)), 7,  "Date")
    equal(tz({ valueOf: function () { return 7 } }), 7, "valueOf")
}
Exemple #24
0
// time](http://en.wikipedia.org/wiki/Unix_time) &mdash; milliseconds since the
// epoch in UTC &mdash; for a cross-platform, internationalized, and durable
// representation of a point in time.
//
// POSIX time is absolute. It always represents a time in UTC. It doesn't spring
// forward or fall back. It's not affected by the decisions of local
// governments or administrators. It is a millisecond in the grand time line.
//
// POSIX time is simple. It is always an integer, making it easy to store in
// databases and data stores, even ones little or no support for time stamps.
//
// Because POSIX is an integer, it time is easy to sort and easy to compare.
// Sorting and searching POSIX time is fast.

// *Timezone returns number representing POSIX time by default.*
var y2k = tz("2000-01-01");

// Unless you provide a format specifier, the return value of a call to the
// **Timezone** function will be POSIX time.

// *The POSIX time number is always an integer, usually quite large.*
eq( y2k, 946684800000 );

// The JavaScript `Date.UTC` function also returns an integer representing POSIX
// time. We will use it check our work in our synopsis.

// *Did **Timezone** give us the correct POSIX time for 2000?*
eq( y2k, Date.UTC(2000, 0, 1) );

// POSIX time is milliseconds since the epoch in UTC. The epoch is New Year's
// 1970. POSIX time for dates before 1970 are negative. POSIX time for dates
Exemple #25
0
var http = require('http')
var tz = require("timezone");
var eu = tz(require("timezone/Europe"));

var DataFetcher = require('./lib/DataFetcher')
var TransportStore = require('./lib/stores/TransportStore')
var RhineStore = require('./lib/stores/RhineStore')
var NetatmoStore = require('./lib/stores/NetatmoStore')
var WeatherStore = require('./lib/stores/WeatherStore')

DataFetcher.setTransportStore(TransportStore);
DataFetcher.setRhineStore(RhineStore);
DataFetcher.setNetatmoStore(NetatmoStore);
DataFetcher.setWeatherStore(WeatherStore);
DataFetcher.start();

var port = process.env.PORT || 3000;
var server = http.createServer();
var io = require('socket.io')(server);
io.on('connection', function(socket){
  console.log("Hello Client!")
  socket.emit('change', getAllData());
  socket.on('disconnect', function(){ console.log("Goodbye Client...") });
});
server.listen(port);
console.log("Socket server listening on "+port)

NetatmoStore.addChangeListener(emitData);
TransportStore.addChangeListener(emitData);
RhineStore.addChangeListener(emitData);
WeatherStore.addChangeListener(emitData);
Exemple #26
0
function prove (assert) {
    var tz = require('timezone'), util = require('../util')
    assert(tz(util.bicentennial, '%C'), '19', 'century')
}
Exemple #27
0
function prove (equal) {
    var tz = require('timezone'), util = require('../util')
    equal(tz(util.utc(1980, 0, 1, 0, 0, 1, 3), '%0003N'), '003', 'padded')
    equal(tz(util.utc(1980, 0, 1, 0, 0, 1, 3), '%_3N'), '  3', 'space padded')
    equal(tz(util.utc(1980, 0, 1), '%-d'), '1', 'unpadded')
}
Exemple #28
0
function prove (assert) {
    var tz = require('timezone'), util = require('../util')
    assert(tz(util.utc(2011, 0, 1, 0, 0), '%M'), '00', 'top of hour')
    assert(tz(util.utc(2011, 0, 1, 0, 1), '%M'), '01', 'minutes')
    assert(tz(util.utc(2011, 0, 1, 0, 59), '%M'), '59', 'last minute')
}