tiny-relative-time 1.0.0 → 1.0.1

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 (2) hide show
  1. package/README.md +27 -15
  2. package/package.json +7 -2
package/README.md CHANGED
@@ -1,25 +1,44 @@
1
1
  tiny-relative-time is a lightweightand versatile package to format dates and timestamps into human-friendly relative times. It works for both JavaScript and TypeScript and supports multiple formatting modes, including natural language and short compact format
2
2
 
3
3
  ✨ Features
4
+
4
5
  Format relative time in natural language:
5
6
  Compact formats
6
7
  Multiple modes for flexibility
7
8
 
8
9
  📦 Installation
10
+
9
11
  Install the package using npm:
10
- npm install tiny-relative-time
12
+ ```npm install tiny-relative-time```
11
13
 
12
14
  🚀 Usage
13
- relTime() works with Date objects, timestamps, or ISO strings. The second argument is one of "natural" | "minuteRounded" | "compact" | "compactMinute" modes. In TypeScript, you can optionally import the Mode type for type safety.”
15
+
16
+ relTime() works with Date objects, timestamps, or ISO strings. The second argument is one of "natural" | "minuteRounded" | "compact" | "compactMinute" modes. In TypeScript, you can optionally import the Mode type for type safety.
17
+
18
+ 🗒️Modes
19
+
20
+ 1. natural: Standard natural language; 10 seconds ago
21
+ 2. minuteRounded: Rounds times to nearest minute; very recent times show "just now"
22
+ 3. compact: Short, concise format; 10s
23
+ 4. compactMinute: Short format with focus on minutes; less than 1 minute shows 0m
24
+
25
+ ✔️Supported Input
26
+
27
+ 1. Date object
28
+ 2. Timestamp (number in milliseconds)
29
+ 3. ISO string ("2026-03-03T12:00:00Z")
14
30
 
15
31
  ⚡JavaScript
32
+ ```
16
33
  const { relTime } = require('tiny-relative-time');
17
34
  console.log(relTime(new Date(Date.now() - 10 * 1000), "natural"));
18
35
  console.log(relTime(Date.now() - 10 * 1000, "minuteRounded"));
19
36
  console.log(relTime(new Date(Date.now() - 10 * 1000).toISOString(), "compact"));
20
- console.log(relTime(Date.now() - 10 * 1000, "compactMinute"));
37
+ console.log(relTime(Date.now() - 10 * 1000, "compactMinute"))
38
+ ```
21
39
 
22
40
  🛡️TypeScript
41
+ ```
23
42
  import { relTime, Mode } from 'tiny-relative-time';
24
43
  const dateInput: Date = new Date(Date.now() - 10 * 1000);
25
44
  const timestampInput: number = Date.now() - 10 * 1000;
@@ -29,18 +48,11 @@ console.log(relTime(dateInput, mode));
29
48
  console.log(relTime(timestampInput, "minuteRounded"));
30
49
  console.log(relTime(isoInput, "compact"));
31
50
  console.log(relTime(timestampInput, "compactMinute"));
51
+ ```
52
+ 🤝 Contributing
32
53
 
33
- 🗒️Modes
34
- 1. natural: Standard natural language; 10 seconds ago
35
- 2. minuteRounded: Rounds times to nearest minute; very recent times show "just now"
36
- 3. compact: Short, concise format; 10s
37
- 4. compactMinute: Short format with focus on minutes; less than 1 minute shows 0m
38
-
39
- ✔️Supported Input
40
- 1. Date object
41
- 2. Timestamp (number in milliseconds)
42
- 3. ISO string ("2023-01-01T12:00:00Z")
54
+ Contributions are welcome! Feel free to open issues or submit pull requests on GitHub.
43
55
 
44
- 🤝 Contributing Contributions are welcome! Feel free to open issues or submit pull requests on GitHub.
56
+ 📄 License
45
57
 
46
- 📄 License This project is licensed under the MIT License.
58
+ This project is licensed under the MIT License.
package/package.json CHANGED
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "name": "tiny-relative-time",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Lightweight relative time package as a formatter for JavaScript and TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/prajaktadhatrak/tiny-relative-time.git"
10
+ },
11
+ "homepage": "https://github.com/prajaktadhatrak/tiny-relative-time/blob/main/README.md",
7
12
  "scripts": {
8
13
  "build": "tsc",
9
14
  "test": "npm run build && node test.js"
10
15
  },
11
- "keywords": ["time ago","time formatter","ago","relative","relative time","date formatter","time difference","javascript time"],
16
+ "keywords": ["time ago","time formatter","ago","relative","relative time","timestamp","time difference","javascript time","js","typescript time","ts"],
12
17
  "author": "Prajakta Dhatrak",
13
18
  "license": "MIT",
14
19
  "devDependencies": {