daily-color 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -0
  2. package/index.js +2 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -18,6 +18,7 @@ In a JavaScript/TypeScript project, using NPM:
18
18
  import { getDailyColor } from "daily-color";
19
19
 
20
20
  console.log("Today's color is:", getDailyColor());
21
+ console.log("Another day's color is:", getDailyColor(new Date("2024-11-09")));
21
22
  ```
22
23
 
23
24
  Directly loading the bundled JavaScript, for static projects not using NPM:
@@ -27,6 +28,7 @@ Directly loading the bundled JavaScript, for static projects not using NPM:
27
28
  import { getDailyColor } from "https://www.aimeerivers.com/daily-color/dist/daily-color.js";
28
29
 
29
30
  console.log("Today's color is:", getDailyColor());
31
+ console.log("Another day's color is:", getDailyColor(new Date("2024-11-09")));
30
32
  </script>
31
33
  ```
32
34
 
package/index.js CHANGED
@@ -1,5 +1,4 @@
1
- export function getDailyColor() {
2
- const date = new Date();
1
+ export function getDailyColor(date = new Date()) {
3
2
  const hash = getSimpleHash(date);
4
3
 
5
4
  const r = (hash >> 16) & 0xff; // Red
@@ -14,7 +13,7 @@ function getSimpleHash(date) {
14
13
  const month = date.getMonth() + 1; // getMonth() is zero-based
15
14
  const year = date.getFullYear();
16
15
 
17
- const dateString = `${year}-${month}-${day}`;
16
+ const dateString = `${day}${day * year * month}${year}${month}${day}${year}${month}${day}`;
18
17
  let hash = 0;
19
18
 
20
19
  // Simple hash function: Iterate over each character in the date string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "daily-color",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "Provides a unique hex code each day",
5
5
  "keywords": [
6
6
  "color",