Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
cctz
Advanced tools
Readme
CCTZ is a C++ library for translating between absolute and civil times using the rules of a time zone.
You will need C++11 compatible compiler to build this binding. For most systems this will work:
$ npm install --save cctz
If you have Ubuntu 12.04, then install clang-3.4
and set-up environment:
$ sudo apt-get install clang-3.4
$ export CXX=clang++
$ export npm_config_clang=1
const {convert, format, CivilTime} = require('cctz');
const unix = convert(new CivilTime(2015, 9, 22, 9), 'America/Los_Angeles');
console.log(format('Talk starts at %T %z (%Z)', unix, 'America/New_York'));
// => Talk starts at 12:00:00 -0400 (EDT)
Converts CivilTime
to unix timestamp and vice versa.
Type: CivilTime
or number
If time
is CivilTime
, then method returns Unix timestamp (without fractional part).
Otherwise returns CivilTime
.
Type: TimeZone
or string
TimeZone objcet, that represents target timezone for converting.
Returns formatted unix timestamp according to timezone.
Type: string
Format of output. See strftime documentation and Google CCTZ sources for syntax.
Type: number
Unix timestamp in seconds (can have fractional part).
Type: TimeZone
or string
Default: local timezone
TimeZone objcet, that represents target timezone for formatting.
Parses input
string according to format
string (assuming input
in timezone
).
Returns unix timestamp or undefined
if parsing failed.
Type: string
Format of input
argument. See strftime documentation and Google CCTZ sources for syntax.
Type: string
Input string to parse.
Type: TimeZone
or string
Default: Timezone from input
or local timezone
Timezone, that should be used in parse. Timezone can be part of input:
cctz.parse('%Y-%m-%d %H:%M:%S %Ez', '2015-09-22 09:35:12+03:00');
Alias for
cctz.load_time_zone
Use this method instead new TimeZone
– because it caches TimeZone
objects inside.
Returns TimeZone
object.
Type: string
Timezone name, that should be loaded from /usr/share/zoneinfo
.
Alias for
Math.floor(Date.now() / 1000)
Returns unix timestamp in seconds. All methods can accept timestamp with fractional milliseconds (if you need such accuracy).
Holder for cctz::civil_second
with getters and setters for properties.
Creates CivilTime object with next properties:
year
– getter and settermonth
– getter and setter [1:12]day
– getter and setter [1:31]hour
– getter and setter [0:23]minute
– getter and setter [0:59]second
– getter and setter [0:59]yearday
– only getter [1:356]weekday
– only getter [0:6]Tip: Fastest way to add amount of time is to add number of seconds to unix timestamp.
Returns new CivilTime object with start of year.
Returns new CivilTime object with start of month.
Returns new CivilTime object with start of day.
Returns new CivilTime object with start of hour.
Returns cloned CivilTime object.
Holder for cctz::time_zone
.
Creates new object with TimeZone.
Returns cctz::absolute_lookup
object.
Returns cctz::civil_lookup
object.
Name of TimeZone.
Format (cctz) x 532,683 ops/sec ±2.80% (78 runs sampled)
(Date) x 191,400 ops/sec ±2.59% (81 runs sampled)
(date-fns) x 91,772 ops/sec ±1.58% (85 runs sampled)
(moment) x 56,508 ops/sec ±6.35% (76 runs sampled)
Parse (cctz) x 1,105,353 ops/sec ±0.59% (86 runs sampled)
(Date) x 1,200,218 ops/sec ±2.00% (82 runs sampled)
(date-fns) x 249,225 ops/sec ±5.00% (77 runs sampled)
(moment) x 23,905 ops/sec ±1.91% (80 runs sampled)
Add hour (cctz) x 6,123,083 ops/sec ±5.39% (82 runs sampled)
(Date) x 3,604,915 ops/sec ±1.13% (69 runs sampled)
(date-fns) x 3,211,900 ops/sec ±2.28% (81 runs sampled)
(moment) x 590,854 ops/sec ±8.48% (72 runs sampled)
Convert Ut->Time (cctz) x 653,305 ops/sec ±9.33% (68 runs sampled)
(moment) x 144,580 ops/sec ±2.18% (83 runs sampled)
Convert Time->Ut (cctz) x 987,437 ops/sec ±11.68% (70 runs sampled)
(moment) x 154,492 ops/sec ±3.54% (82 runs sampled)
Run npm i
and then npm run bench
.
MIT © Vsevolod Strukchinsky
FAQs
⚡️ Fast parsing, formatting and timezone manipulations for dates
The npm package cctz receives a total of 12 weekly downloads. As such, cctz popularity was classified as not popular.
We found that cctz demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.