global-clock v2.3.3
Global-Clock
What is this?
An Easy and lightweight package for getting time and date for any location!
Installation
For npm:
npm install global-clock --save
For yarn:
yarn add global-clock
Then...
For commonjs:
const { Clock } = require('global-clock');
Clock.getTime();For module:
import { Clock } from 'global-clock';
Clock.getTime();Clock
Clock supports 5 options:
Clock.getTime(<parameters: withSeconds, location>)- Returns time in the AM/PM format
EX:
Clock.getTime(); // 5:00:00 PMClock.getFullTime(<parameters: withSeconds, location>)- Returns time in military time
EX:
Clock.getFullTime(); // 17:00:00Clock.getDate(<parameters: type, location>)- Returns the date
EX:
Clock.getDate(); // 1/8/2021Clock.getDateTime(<parameters: type, withSeconds, location>)- Returns the date and the time in the AM/PM format
EX:
Clock.getDateTime(); // 1/8/2021 5:00:00 PMClock.getDateFullTime(<parameters: type, withSeconds, location>)- Returns the date and the time in military time
EX:
Clock.getDateFullTime(); // 1/8/2021 17:00:00Clock Parameters
withSecondsnot required, not case sensitive - Seconds included?There are 2 different possible values for withSeconds:
true- It would return the time in this format:5:00:00 PM
EX:
Clock.getDate(true); // 5:00:00 PMfalse- It would return the time in this format:5:00 PM
EX:
Clock.getDate(false); // 5:00 PMIf the withSeconds is undefined time would automaticly output in this format 5:00:00 PM
locationnot required, not case sensitive - Location is the location where you want the time from.
You CANNOT put a random location, this only works with official timezones, you can get more information about this at: https://www.iana.org/time-zones
If the location is undefined the location would automaticly output to your current location
EX:
Clock.getTime(location);
Clock.getTime('california'); // 5:00:00 PMtypenot required, not case sensitive - Type is used for dates, this is responsible for the order that the date is in.There are 3 different possible values for type:
mm/dd/yyormm/dd/yyyyOutput:
Clock.getDate('mm/dd/yy'); // 1/8/2021
Clock.getDate('mm/dd/yyyy'); // 1/8/2021dd/mm/yyordd/mm/yyyyOutput:
Clock.getDate('dd/mm/yy'); // 8/1/2021
Clock.getDate('dd/mm/yyyy'); // 8/1/2021yy/mm/ddoryyyy/mm/ddOutput:
Clock.getDate('yy/mm/dd'); // 2021/1/8
Clock.getDate('yyyy/mm/dd'); // 2021/1/8You can use both dd/mm/yy or dd/mm/yyyy
EX:
Clock.getDate(type);
Clock.getDate('dd/mm/yy'); // 8/1/2021
Clock.getDate('dd/mm/yyyy'); // 8/1/2021If the type is undefined the date would automaticly output in this format mm/dd/yyyy
An Example of global-clock being used:
https://codesandbox.io/s/global-clock-example-qx4fc?file=/src/App.js
HTMLClock
! This does not work with pure HTML and JS
You would need to use something like Parcel or Webpack Parcel: https://parceljs.org/
Webpack: https://webpack.js.org/ HTMLClock supports 1 option:
HTMLClock.createClock(<object>)- This creates a clock element
EX:
// JS
import { HTMLClock } from 'global-clock';
const options = {
class: 'clock',
type: 'text',
time: 'normal',
};
HTMLClock.createClock(options);// HTML
<div class="clock"></div>
<!-- the object that turns into the clock -->
<div class="not-clock"></div>
<!-- NOT the object that turns into the clock -->// RESULT
<div
class="clock"
style="display:flex;alignItems:center;justifyContent:center;"
>
<p
class="clock-time"
style="color:#fff;font-family:arial;font-size:1.5em;font-weight:200;"
>
The Time
</p>
</div>
<div class="not-clock"></div>The <p></p> tag's class would always be the main class name and-time(in this case clock-time)
To overwrite the inline CSS you can use !important
EX:
.clock {
background: #eeffff !important;
}
.clock-time {
color: #000 !important;
font-size: 20px !important;
}HTMLClock Object
classrequired, case sensitive - This would be the class that would become the clock elementtypenot required, case sensitive - This is the type of clock element you wanttext- An invisible<div></div>element with a<p></p>element that says the time inside of itbox- A box with a<p></p>element that says the time inside of it
If you leave blank or
undefinedit will default totextwithSecodsnot required, not case sensitive - Seconds included?locationnot required, not case sensitive - The location that you want the time fromIf you leave blank or
undefinedit will default to your current locationtimenot required, case sensitive - Which type of time do you wantnormal- Returns time in the AM/PM formatfull- Returns time in military time
If you leave blank or
undefinedit will default tonormal
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago