react-live-clock
Advanced tools
Comparing version 1.0.1 to 1.1.0
{ | ||
"name": "react-live-clock", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "React Live Clock", | ||
@@ -5,0 +5,0 @@ "main": [ |
@@ -17,6 +17,10 @@ 'use strict'; | ||
var _reactMoment = require('react-moment'); | ||
var _dateformat = require('dateformat'); | ||
var _reactMoment2 = _interopRequireDefault(_reactMoment); | ||
var _dateformat2 = _interopRequireDefault(_dateformat); | ||
var _loaded = require('timezone/loaded'); | ||
var _loaded2 = _interopRequireDefault(_loaded); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -32,3 +36,3 @@ | ||
var getDate = function getDate(date) { | ||
return date ? date : new Date().getTime(); | ||
return date ? new Date(date).getTime() : new Date().getTime(); | ||
}; | ||
@@ -67,3 +71,2 @@ | ||
var _props = this.props, | ||
ago = _props.ago, | ||
children = _props.children, | ||
@@ -73,23 +76,15 @@ className = _props.className, | ||
format = _props.format, | ||
from = _props.from, | ||
fromNow = _props.fromNow, | ||
parse = _props.parse, | ||
timezone = _props.timezone, | ||
to = _props.to, | ||
toNow = _props.toNow, | ||
unix = _props.unix; | ||
locale = _props.locale, | ||
timezone = _props.timezone; | ||
var dateValue = getDate(date || children); | ||
var utc = (0, _loaded2.default)(dateValue); | ||
var localizedTime = (0, _loaded2.default)(utc, '%x %X', locale, timezone); | ||
var formattedTime = (0, _dateformat2.default)(new Date(localizedTime), format); | ||
return _react2.default.createElement(_reactMoment2.default, { | ||
ago: ago, | ||
className: className, | ||
date: getDate(date || children), | ||
format: format, | ||
from: from, | ||
fromNow: fromNow, | ||
parse: parse, | ||
to: to, | ||
toNow: toNow, | ||
tz: timezone, | ||
unix: unix }); | ||
return _react2.default.createElement( | ||
'time', | ||
{ className: className }, | ||
formattedTime | ||
); | ||
} | ||
@@ -105,3 +100,2 @@ }]); | ||
ReactLiveClock.propTypes = { | ||
ago: _propTypes2.default.bool, | ||
children: _propTypes2.default.string, | ||
@@ -111,10 +105,4 @@ className: _propTypes2.default.string, | ||
format: _propTypes2.default.string, | ||
from: _propTypes2.default.string, | ||
fromNow: _propTypes2.default.bool, | ||
interval: _propTypes2.default.number, | ||
// locale: PropTypes.string, | ||
parse: _propTypes2.default.string, | ||
to: _propTypes2.default.string, | ||
toNow: _propTypes2.default.bool, | ||
unix: _propTypes2.default.bool, | ||
locale: _propTypes2.default.string, | ||
ticking: _propTypes2.default.bool, | ||
@@ -125,14 +113,7 @@ timezone: _propTypes2.default.string | ||
ReactLiveClock.defaultProps = { | ||
ago: false, | ||
className: null, | ||
date: null, | ||
format: 'HH:mm', | ||
from: null, | ||
fromNow: false, | ||
format: 'HH:MM', | ||
interval: 1000, | ||
// locale: null, | ||
parse: null, | ||
to: null, | ||
toNow: false, | ||
unix: false, | ||
locale: 'en_US', | ||
ticking: false, | ||
@@ -139,0 +120,0 @@ timezone: null |
{ | ||
"name": "react-live-clock", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "React Live Clock", | ||
@@ -23,5 +23,7 @@ "main": "lib/index.js", | ||
"keywords": [ | ||
"component", | ||
"react-component", | ||
"react" | ||
"react", | ||
"date", | ||
"time", | ||
"clock", | ||
"timezones" | ||
], | ||
@@ -42,7 +44,6 @@ "author": "Pavlo Vozniuk <pavlo.vozniuk@gmail.com>", | ||
"dependencies": { | ||
"dateformat": "2.0.0", | ||
"prop-types": "15.5.10", | ||
"react-moment": "0.2.2", | ||
"moment": "2.18.1", | ||
"moment-timezone": "0.5.13" | ||
"timezone": "1.0.6" | ||
} | ||
} |
@@ -78,3 +78,3 @@ # react-live-clock [![npm](https://img.shields.io/npm/v/react-live-clock.svg?style=flat-square)](https://www.npmjs.com/package/react-live-clock) | ||
** you can use any formatting from [moment](http://momentjs.com/) date library | ||
** you can use any formatting from [node-dateformat](https://github.com/felixge/node-dateformat) date library | ||
@@ -81,0 +81,0 @@ |
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Moment from 'react-moment'; | ||
import dateFormat from 'dateformat'; | ||
import tz from 'timezone/loaded'; | ||
let tickTimer; | ||
const getDate = date => date ? date : new Date().getTime(); | ||
const getDate = date => date ? new Date(date).getTime() : new Date().getTime(); | ||
@@ -24,18 +25,10 @@ export default class ReactLiveClock extends React.Component { | ||
render() { | ||
const {ago, children, className, date, format, from, fromNow, | ||
/*locale,*/ parse, timezone, to, toNow, unix} = this.props; | ||
const {children, className, date, format, locale, timezone} = this.props; | ||
const dateValue = getDate(date || children); | ||
const utc = tz(dateValue); | ||
const localizedTime = tz(utc, '%x %X', locale, timezone); | ||
const formattedTime = dateFormat(new Date(localizedTime), format); | ||
return ( | ||
<Moment | ||
ago={ago} | ||
className={className} | ||
date={getDate(date || children)} | ||
format={format} | ||
from={from} | ||
fromNow={fromNow} | ||
parse={parse} | ||
to={to} | ||
toNow={toNow} | ||
tz={timezone} | ||
unix={unix} /> | ||
<time className={className}>{ formattedTime }</time> | ||
); | ||
@@ -46,3 +39,2 @@ } | ||
ReactLiveClock.propTypes = { | ||
ago: PropTypes.bool, | ||
children: PropTypes.string, | ||
@@ -55,10 +47,4 @@ className: PropTypes.string, | ||
format: PropTypes.string, | ||
from: PropTypes.string, | ||
fromNow: PropTypes.bool, | ||
interval: PropTypes.number, | ||
// locale: PropTypes.string, | ||
parse: PropTypes.string, | ||
to: PropTypes.string, | ||
toNow: PropTypes.bool, | ||
unix: PropTypes.bool, | ||
locale: PropTypes.string, | ||
ticking: PropTypes.bool, | ||
@@ -69,16 +55,9 @@ timezone: PropTypes.string | ||
ReactLiveClock.defaultProps = { | ||
ago: false, | ||
className: null, | ||
date: null, | ||
format: 'HH:mm', | ||
from: null, | ||
fromNow: false, | ||
format: 'HH:MM', | ||
interval: 1000, | ||
// locale: null, | ||
parse: null, | ||
to: null, | ||
toNow: false, | ||
unix: false, | ||
locale: 'en_US', | ||
ticking: false, | ||
timezone: null | ||
}; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
13241488
4
52669
0
1
+ Addeddateformat@2.0.0
+ Addedtimezone@1.0.6
+ Addeddateformat@2.0.0(transitive)
+ Addedtimezone@1.0.6(transitive)
- Removedmoment@2.18.1
- Removedmoment-timezone@0.5.13
- Removedreact-moment@0.2.2
- Removedmoment@2.18.1(transitive)
- Removedmoment-timezone@0.5.13(transitive)
- Removedreact-moment@0.2.2(transitive)