tiny-relative-time 1.0.0 → 1.0.2

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 +44 -23
  2. package/package.json +21 -16
package/README.md CHANGED
@@ -1,26 +1,54 @@
1
+ # Relative Time
1
2
  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
3
 
3
- Features
4
- Format relative time in natural language:
5
- Compact formats
6
- Multiple modes for flexibility
4
+ # ✨Features
5
+
6
+ Format relative time in natural language:
7
+ Compact formats
8
+ • Multiple modes for flexibility
9
+
10
+ # 📦Installation
7
11
 
8
- 📦 Installation
9
12
  Install the package using npm:
10
- npm install tiny-relative-time
13
+ ```npm install tiny-relative-time```
14
+
15
+ # 🚀Usage
16
+
17
+ 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.
18
+
19
+ # 🗒️Modes
20
+
21
+ 1. natural: Standard natural language; 10 seconds ago
22
+ 2. minuteRounded: Rounds times to nearest minute; very recent times show "just now"
23
+ 3. compact: Short, concise format; 10s
24
+ 4. compactMinute: Short format with focus on minutes; less than 1 minute shows 0m
11
25
 
12
- 🚀 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.”
26
+ # ✔️Supported Input
14
27
 
15
- ⚡JavaScript
28
+ 1. Date object
29
+ 2. Timestamp (number in milliseconds)
30
+ 3. ISO string ("2026-03-03T12:00:00Z")
31
+
32
+ ## ⚡JavaScript
33
+ ### Import the Package
34
+ ```
16
35
  const { relTime } = require('tiny-relative-time');
36
+ ```
37
+ ### Get relative time for different input
38
+ ```
17
39
  console.log(relTime(new Date(Date.now() - 10 * 1000), "natural"));
18
40
  console.log(relTime(Date.now() - 10 * 1000, "minuteRounded"));
19
41
  console.log(relTime(new Date(Date.now() - 10 * 1000).toISOString(), "compact"));
20
- console.log(relTime(Date.now() - 10 * 1000, "compactMinute"));
42
+ console.log(relTime(Date.now() - 10 * 1000, "compactMinute"))
43
+ ```
21
44
 
22
- 🛡️TypeScript
45
+ ## 🛡️TypeScript
46
+ ### Import the Package
47
+ ```
23
48
  import { relTime, Mode } from 'tiny-relative-time';
49
+ ```
50
+ ### Get relative time different input
51
+ ```
24
52
  const dateInput: Date = new Date(Date.now() - 10 * 1000);
25
53
  const timestampInput: number = Date.now() - 10 * 1000;
26
54
  const isoInput: string = new Date(Date.now() - 10 * 1000).toISOString();
@@ -29,18 +57,11 @@ console.log(relTime(dateInput, mode));
29
57
  console.log(relTime(timestampInput, "minuteRounded"));
30
58
  console.log(relTime(isoInput, "compact"));
31
59
  console.log(relTime(timestampInput, "compactMinute"));
60
+ ```
61
+ # 🤝Contributing
32
62
 
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")
63
+ Contributions are welcome! Feel free to open issues or submit pull requests on GitHub.
43
64
 
44
- 🤝 Contributing Contributions are welcome! Feel free to open issues or submit pull requests on GitHub.
65
+ # 📄License
45
66
 
46
- 📄 License This project is licensed under the MIT License.
67
+ This project is licensed under the MIT License.
package/package.json CHANGED
@@ -1,17 +1,22 @@
1
- {
2
- "name": "tiny-relative-time",
3
- "version": "1.0.0",
4
- "description": "Lightweight relative time package as a formatter for JavaScript and TypeScript",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "scripts": {
8
- "build": "tsc",
9
- "test": "npm run build && node test.js"
10
- },
11
- "keywords": ["time ago","time formatter","ago","relative","relative time","date formatter","time difference","javascript time"],
12
- "author": "Prajakta Dhatrak",
13
- "license": "MIT",
14
- "devDependencies": {
15
- "typescript": "^5.9.3"
16
- }
1
+ {
2
+ "name": "tiny-relative-time",
3
+ "version": "1.0.2",
4
+ "description": "Lightweight relative time package as a formatter for JavaScript and TypeScript",
5
+ "main": "dist/index.js",
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",
12
+ "scripts": {
13
+ "build": "tsc",
14
+ "test": "npm run build && node test.js"
15
+ },
16
+ "keywords": ["time ago","time formatter","ago","relative","relative time","timestamp","time difference","javascript time","js","typescript time","ts","moment"],
17
+ "author": "Prajakta Dhatrak",
18
+ "license": "MIT",
19
+ "devDependencies": {
20
+ "typescript": "^5.9.3"
21
+ }
17
22
  }