country-live-clocks
Advanced tools
Comparing version 1.0.1 to 1.0.2
23
index.js
@@ -323,14 +323,17 @@ /** | ||
*/ | ||
function getCountryLiveClock(countryCode) { | ||
if (!countryCode) throw new Error("Country Code is required"); | ||
const timezonesForCountry = getTimezonesForCountry(countryCode.toUpperCase()); | ||
if (!timezonesForCountry?.length) throw new Error("Invalid Country Code"); | ||
return timezonesForCountry.slice(0, 5).map(({ name: timezone }) => ({ | ||
timezone, | ||
time: new Date().toLocaleTimeString('en-US', { timeZone: timezone, hour12: true, timeStyle: 'short' }) | ||
})); | ||
async function getCountryLiveClock(countryCode) { | ||
return new Promise((resolve, reject) => { | ||
if (!countryCode) reject(new Error("Country Code is required")); | ||
const timezonesForCountry = getTimezonesForCountry(countryCode.toUpperCase()); | ||
if (!timezonesForCountry?.length) reject(new Error("Invalid Country Code")); | ||
const result = timezonesForCountry.slice(0, 5).map(({ name: timezone }) => ({ | ||
timezone, | ||
time: new Date().toLocaleTimeString('en-US', { timeZone: timezone, hour12: true, timeStyle: 'short' }) | ||
})); | ||
resolve(result); | ||
}); | ||
} | ||
module.exports = getCountryLiveClock; |
{ | ||
"name": "country-live-clocks", | ||
"version": "1.0.1", | ||
"description": "Country Live Clock is a versatile npm package designed to provide real-time timezone information for any country. By simply passing a country code, users can retrieve an array of objects detailing the current time across all the time zones within that country. Whether you're building applications that require accurate global time display, scheduling software that spans multiple time zones, or just need a quick way to check the time in different parts of a country, Country Live Clock offers a straightforward and efficient solution.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node test.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ankitjha-webdev/CountryLiveClocks.git" | ||
}, | ||
"keywords": [ | ||
"time zones", | ||
"country time", | ||
"world clock", | ||
"timezone converter", | ||
"timezone", | ||
"local time", | ||
"global clock", | ||
"country code", | ||
"time API", | ||
"live clock", | ||
"time utility", | ||
"international time", | ||
"timezone lookup", | ||
"country timezone", | ||
"clock", | ||
"React", | ||
"Vue", | ||
"Angular", | ||
"Node.js", | ||
"JavaScript", | ||
"frontend", | ||
"backend", | ||
"web development" | ||
], | ||
"author": "Ankit Kumar <ankitjha-webdev@example.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/ankitjha-webdev/CountryLiveClocks/issues" | ||
}, | ||
"homepage": "https://github.com/ankitjha-webdev/CountryLiveClocks#readme" | ||
} | ||
"name": "country-live-clocks", | ||
"version": "1.0.2", | ||
"description": "Country Live Clock is a versatile npm package designed to provide real-time timezone information for any country. By simply passing a country code, users can retrieve an array of objects detailing the current time across all the time zones within that country. Whether you're building applications that require accurate global time display, scheduling software that spans multiple time zones, or just need a quick way to check the time in different parts of a country, Country Live Clock offers a straightforward and efficient solution.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "node test.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ankitjha-webdev/CountryLiveClocks.git" | ||
}, | ||
"keywords": [ | ||
"time zones", | ||
"country time", | ||
"world clock", | ||
"timezone converter", | ||
"timezone", | ||
"local time", | ||
"global clock", | ||
"country code", | ||
"time API", | ||
"live clock", | ||
"time utility", | ||
"international time", | ||
"timezone lookup", | ||
"country timezone", | ||
"clock", | ||
"React", | ||
"Vue", | ||
"Angular", | ||
"Node.js", | ||
"JavaScript", | ||
"frontend", | ||
"backend", | ||
"web development" | ||
], | ||
"author": "Ankit Kumar <ankitjha-webdev@example.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/ankitjha-webdev/CountryLiveClocks/issues" | ||
}, | ||
"homepage": "https://github.com/ankitjha-webdev/CountryLiveClocks#readme" | ||
} |
@@ -15,6 +15,7 @@ # Country Live Clocks | ||
bash | ||
npm install country-live-clocks | ||
```bash | ||
foo@bar:~$ npm install country-live-clocks | ||
0 vulnerabilities | ||
``` | ||
## Usage | ||
@@ -24,12 +25,12 @@ | ||
javascript | ||
```javascript | ||
const { getCountryLiveClock } = require('country-live-clocks'); | ||
// Replace 'US' with the country code you're interested in | ||
getCountryLiveClock('US').then(timezones => { | ||
getCountryLiveClock('US').then(timezones => { | ||
console.log(timezones); | ||
}).catch(error => { | ||
}).catch(error => { | ||
console.error('Error fetching timezones:', error); | ||
}); | ||
``` | ||
## API | ||
@@ -36,0 +37,0 @@ |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
8
0
100
56
20201
318
1