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