{"name":"time","description":"\"time.h\" bindings for Node.js","keywords":["date","time","time.h","timezone","setTimezone","getTimezone"],"version":"0.11.4","repository":{"type":"git","url":"git://github.com/TooTallNate/node-time.git"},"author":{"name":"Nathan Rajlich","email":"nathan@tootallnate.net","url":"http://tootallnate.net"},"license":"MIT","contributors":[{"name":"Diogo Resende","email":"dresende@thinkdigital.pt"}],"main":"./index.js","scripts":{"test":"mocha --reporter spec","install":"node-gyp rebuild"},"dependencies":{"bindings":"~1.2.0","debug":"2","nan":"2"},"devDependencies":{"mocha":"*"},"gypfile":true,"gitHead":"3faced83e4933ffa45f8aacb19bee74b1811022c","bugs":{"url":"https://github.com/TooTallNate/node-time/issues"},"homepage":"https://github.com/TooTallNate/node-time#readme","_id":"time@0.11.4","_shasum":"ec3c8947d7fa488f3b1978b8110a68186f5d340f","_from":".","_npmVersion":"2.11.2","_nodeVersion":"0.12.6","_npmUser":{"name":"tootallnate","email":"nathan@tootallnate.net"},"maintainers":[{"name":"TooTallNate","email":"nathan@tootallnate.net"},{"name":"tootallnate","email":"nathan@tootallnate.net"}],"dist":{"shasum":"ec3c8947d7fa488f3b1978b8110a68186f5d340f","tarball":"http://registry-npm.ywwl.com/time/download/time-0.11.4.tgz","integrity":"sha512-RwiPHFIG/zIfjdHtsYbAB+6mVsZj6nNm3THBdQMbc/ieAKxN60Bizdeho4e3PUju95f4/Yo5jSczSqnFgShayQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGZKMzyDhV6KrAb8QKCzi2s3ShXwnH+/3+tI140FBz+LAiACaFuNzEDoSIWOfwCFc2FkWODm1a1oTCJCRrdmGlYOnA=="}],"size":13628,"noattachment":false,"key":"/time/-/time-0.11.4.tgz"},"readme":"node-time\n=========\n### \"[time.h][]\" bindings for [Node.js][Node].\n[![Build Status](https://travis-ci.org/TooTallNate/node-time.svg?branch=master)](https://travis-ci.org/TooTallNate/node-time)\n[![Build Status](https://ci.appveyor.com/api/projects/status/weml61hm3ebh5mnt/branch/master?svg=true)](https://ci.appveyor.com/project/TooTallNate/node-time/branch/master)\n\n\nThis module offers simple bindings for the C [time.h][] APIs.\nIt also offers an extended native `Date` object with `getTimezone()`\nand `setTimezone()` functions, which aren't normally part of JavaScript.\n\n\nInstallation\n------------\n\n`node-time` is available through npm:\n\n``` bash\n$ npm install time\n```\n\n\nExample\n-------\n\n``` javascript\nvar time = require('time');\n\n// Create a new Date instance, representing the current instant in time\nvar now = new time.Date();\n\nnow.setTimezone(\"America/Los_Angeles\");\n// `.getDate()`, `.getDay()`, `.getHours()`, etc.\n// will return values according to UTC-8\n\nnow.setTimezone(\"America/New_York\");\n// `.getDate()`, `.getDay()`, `.getHours()`, etc.\n// will return values according to UTC-5\n\n\n// You can also set the timezone during instantiation\nvar azDate = new time.Date(2010, 0, 1, 'America/Phoenix');\nazDate.getTimezone(); // 'America/Phoenix'\n```\n\n### Extending the global `Date` object\n\n`node-time` provides a convenient `time.Date` object, which is its own Date\nconstructor independent from your own (or the global) Date object. There are often\ntimes, however, when you would like the benefits of node-time on *all* Date\ninstances. To extend the global Date object, simply pass it in as an argument to\nthe node-time module when requiring:\n\n``` js\nvar time = require('time')(Date);\n\nvar d = new Date();\nd.setTimezone('UTC');\n```\n\n\nAPI\n---\n\n\n### Date() -> Date\n#### new time.Date()\n#### new time.Date(millisecondsFromUTC)\n#### new time.Date(dateString [, timezone ])\n#### new time.Date(year, month, day [, hour, minute, second, millisecond ] [, timezone ])\n\nA special `Date` constructor that returns a \"super\" Date instance, that has\nmagic _timezone_ capabilities! You can also pass a `timezone` as the last\nargument in order to have a Date instance in the specified timezone.\n\n``` javascript\nvar now = new time.Date();\nvar another = new time.Date('Aug 9, 1995', 'UTC');\nvar more = new time.Date(1970, 0, 1, 'Europe/Amsterdam');\n```\n\n\n#### date.setTimezone(timezone [, relative ]) -> Undefined\n\nSets the timezone for the `Date` instance. By default this function makes it so\nthat calls to `getHours()`, `getDays()`, `getMinutes()`, etc. will be relative to\nthe timezone specified. If you pass `true` in as the second argument, then\ninstead of adjusting the local \"get\" functions to match the specified timezone,\ninstead the internal state of the Date instance is changed, such that the local\n\"get\" functions retain their values from before the setTimezone call.\n\n``` javascript\ndate.setTimezone(\"America/Argentina/San_Juan\")\n\n// Default behavior:\na = new time.Date()\na.toString()\n// 'Wed Aug 31 2011 09:45:31 GMT-0700 (PDT)'\na.setTimezone('UTC')\na.toString()\n// 'Wed Aug 31 2011 16:45:31 GMT+0000 (UTC)'\n\n// Relative behavior:\nb = new time.Date()\nb.toString()\n// 'Wed Aug 31 2011 10:48:03 GMT-0700 (PDT)'\nb.setTimezone('UTC', true)\nb.toString()\n// 'Wed Aug 31 2011 10:48:03 GMT+0000 (UTC)'\n```\n\n\n#### date.getTimezone() -> String\n\nReturns a String containing the currently configured timezone for the date instance.\nThis must be called _after_ `setTimezone()` has been called.\n\n``` javascript\ndate.getTimezone();\n  // \"America/Argentina/San_Juan\"\n```\n\n\n#### date.getTimezoneAbbr() -> String\n\nReturns the abbreviated timezone name, also taking daylight savings into consideration.\nUseful for the presentation layer of a Date instance.\n\n``` javascript\ndate.getTimezoneAbbr();\n  // \"ART\"\n```\n\n\n### Date.parse(dateStr [, timezone ]) -> Number\n\nSame as the native JavaScript `Date.parse()` function, only this version allows\nfor a second, optional, `timezone` argument, which specifies the timezone in\nwhich the date string parsing will be resolved against. This function is also\naliased as `time.parse()`.\n\n``` javascript\ntime.Date.parse(\"1970, January 1\");  // <- Local Time\n  // 28800000\ntime.Date.parse(\"1970, January 1\", \"Europe/Copenhagen\");\n  // -3600000\ntime.Date.parse(\"1970, January 1\", \"UTC\");\n  // 0\n```\n\n\n### extend(date) -> Date\n\nTransforms a \"regular\" Date instance into one of `node-time`'s \"extended\" Date instances.\n\n``` javascript\nvar d = new Date();\n// `d.setTimezone()` does not exist...\ntime.extend(d);\nd.setTimezone(\"UTC\");\n```\n\n\n### time() -> Number\n\nBinding for `time()`. Returns the number of seconds since Jan 1, 1900 UTC.\nThese two are equivalent:\n\n``` javascript\ntime.time();\n  // 1299827226\nMath.floor(Date.now() / 1000);\n  // 1299827226\n```\n\n\n### tzset(timezone) -> Object\n\nBinding for `tzset()`. Sets up the timezone information that `localtime()` will\nuse based on the specified _timezone_ variable, or the current `process.env.TZ`\nvalue if none is specified. Returns an Object containing information about the\nnewly set timezone, or throws an Error if no timezone information could be loaded\nfor the specified timezone.\n\n``` javascript\ntime.tzset('US/Pacific');\n  // { tzname: [ 'PST', 'PDT' ],\n  //   timezone: 28800,\n  //   daylight: 1 }\n```\n\n\n### localtime(Number) -> Object\n\nBinding for `localtime()`. Accepts a Number with the number of seconds since the\nEpoch (i.e. the result of `time()`), and returns a \"broken-down\" Object\nrepresentation of the timestamp, according the the currently configured timezone\n(see `tzset()`).\n\n``` javascript\ntime.localtime(Date.now()/1000);\n  // { seconds: 38,\n  //   minutes: 7,\n  //   hours: 23,\n  //   dayOfMonth: 10,\n  //   month: 2,\n  //   year: 111,\n  //   dayOfWeek: 4,\n  //   dayOfYear: 68,\n  //   isDaylightSavings: false,\n  //   gmtOffset: -28800,\n  //   timezone: 'PST' }\n```\n\n\n### currentTimezone -> String\n\nThe `currentTimezone` property always contains a String to the current timezone\nbeing used by `node-time`. This property is reset every time the `tzset()`\nfunction is called. Individual `time.Date` instances may have independent\ntimezone settings than what this one is...\n\n\n[Node]: http://nodejs.org\n[time.h]: http://en.wikipedia.org/wiki/Time.h\n","publish_time":1440782704223,"_cnpm_publish_time":1440782704223,"dist-tags":{"latest":"0.12.0"}}