Socket
Socket
Sign inDemoInstall

react-live-clock

Package Overview
Dependencies
9
Maintainers
2
Versions
87
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-live-clock

React Live Clock


Version published
Weekly downloads
8.3K
decreased by-42.57%
Maintainers
2
Install size
16.5 MB
Created
Weekly downloads
 

Changelog

Source

[6.1.20]

Bump eslint-plugin-react from 7.33.2 to 7.34.0 Bump es5-ext from 0.10.62 to 0.10.64 (#313) Bump react-router-dom from 6.21.1 to 6.22.2 (#314) Bump eslint from 8.56.0 to 8.57.0 (#312) Bump moment-timezone from 0.5.43 to 0.5.45 (#310) Bump follow-redirects from 1.15.3 to 1.15.4 (#306) Bump moment from 2.29.4 to 2.30.1 (#304)

Readme

Source

react-live-clock npm

Gitter Dependencies Dev Dependencies

React clock with time-zones DEMO

Installation

NPM

npm install --save react react-live-clock

Don't forget to manually install peer dependencies (react) if you use npm@3.

Demo

http://pvoznyuk.github.io/react-live-clock

Usage

import React  from 'react';
import Clock from 'react-live-clock';

exports default class MyComponent extends React.Component {
    render() {
        <Clock format={'HH:mm:ss'} ticking={true} timezone={'US/Pacific'} />
    }
}

Outputs:

<time>10:15:34</time>

** Shows current time for 'US/Pacific' timezone and updates every second

React Native

React Native requires that you wrap text in a <Text> like this:

import { Text, View } from "react-native";
import Clock from "react-live-clock";

export default function ClockPage() {
  return (
    <View>
      <Text>Clock page</Text>
      <Clock element={Text} />
    </View>
  );
}

If you don't you will get the error Invariant Violation: Text strings must be rendered within a <Text> component.

Formatting

you can use any formatting from moment.js date library

Properties

PropertyTypeDefault ValueDescription
datetimestamp or stringcurrent dateDate to output, If nothing is set then it take current date.
formatstring'HH:MM'Formatting from moment.js library.
localestringnullChanges the language of the component via prop
filterfunction(date: String) => dateFiltering the value before the output .
timezonestringnullIf timezone is set, the date is show in this timezone. You can find the list. here, the TZ column.
tickingbooleanfalseIf you want the clock to be auto-updated every interval seconds.
blinkingboolean, stringfalseIf you want the clock's last colon to blink. Set it to all to make them all blink.
noSsrbooleanfalseMakes the component not render on the server to fix mismatch.
intervalinteger1000Auto-updating period for the clock. 1 second is a default value.
classNamestringnullExtra class.
styleCSSPropertiesnullCSSProperties Customized inline style .
childrenstringnulldate can be set as a children prop.
onChangefunction({output, previousOutput, moment}) => {}callback function on each output update

Development and testing

Currently is being developed and tested with the latest stable Node 7 on OSX and Windows.

To run example covering all ReactLiveClock features, use npm start dev, which will compile src/example/Example.js

git clone git@github.com:pvoznyuk/react-live-clock.git
cd react-live-clock
npm install
npm start dev

# then
open http://localhost:8080

Tests

# to run tests
npm start test

# to generate test coverage (./reports/coverage)
npm start test.cov

# to run end-to-end tests
npm start test.e2e

License

This software is released under the MIT license. See LICENSE for more details.

Contributors

Keywords

FAQs

Last updated on 04 Mar 2024

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc