Skip to content

Commit 8f50c5d

Browse files
added new features date-time format
1 parent 76081d8 commit 8f50c5d

5 files changed

Lines changed: 382 additions & 5 deletions

File tree

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Indian Modassir <indianmodassir@gmail.com>

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Release Notes
22

3+
## [v2.1.0](https://github.com/jsvibe/printfy/compare/v2.0.5...v2.1.0) - 11 September 2025
4+
5+
- Add new features `Date-Time` Format (e.g., `$d`, `$m`, `$y`, `$h`, `$i`, `$s`, `$A`) see all `DT` [specifiers](https://github.com/jsvibe/printfy?tab=readme-ov-file#supported-specifiers-1)
6+
37
## [v2.0.5](https://github.com/jsvibe/printfy/compare/v2.0.4...v2.0.5) - 23 August 2025
48

59
- Fixed bugs likes `padding`, `width`, `precision`, `swapping` etc. to improved better than previous version [2.0.4] [@indianmodassir](https://github.com/indianmodassir)

README.md

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Features
2828
- Handles NaN, Infinity and signed values.
2929
- Works in **Node.js**, modern browsers, and CommonJS/AMD environments.
3030
- No external dependencies
31+
- Added Date-Time Format feature from [v2.1.x] Fully functional `$d-$m-$y $h:$i:$s $A`
3132

3233
---
3334

@@ -61,7 +62,7 @@ Below are some of the most common ways to include printfy.
6162
**CDN Link**
6263

6364
```html
64-
<script src="https://cdn.jsdelivr.net/npm/printfy@2.0.5/dist/printfy.min.js"></script>
65+
<script src="https://cdn.jsdelivr.net/npm/printfy@2.1.0/dist/printfy.min.js"></script>
6566
```
6667

6768
You can add the script manually to your project:
@@ -140,9 +141,9 @@ vsprintf("User: %s, Score: %d", ["Bob", 100]);
140141
Supported Specifiers
141142
--------------------
142143

143-
| Specifier | Meaning | Example |
144+
| Specifier | Description | Example |
144145
|-----------|---------------------------------------|---------------------------------|
145-
| `%s` | String | `sprintf("%s", "abc")``"abc"` |
146+
| `%s` | String | `sprintf("%s", "abc")``"abc"`|
146147
| `%S` | Uppercase string | `"abc"``"ABC"` |
147148
| `%d` | Integer (decimal) | `42` |
148149
| `%u` | Unsigned integer (64-bit) | `-1``"18446744073709551615"` |
@@ -157,6 +158,43 @@ Supported Specifiers
157158

158159
---
159160

161+
## Supported Specifiers
162+
163+
| Specifier | Description |
164+
|-----------|----------------------------------------------------------------------------------------------------------|
165+
| $d | Day of the month, 2 digits with leading zeros (e.g., `01` to `31`) |
166+
| $D | A textual representation of a day, three letters (e.g., `Mon` to `Sun`) |
167+
| $j | Day of the month without leading zeros (e.g., `1` to `31`) |
168+
| $l | (lowercase 'L'): A full textual representation of the day of the week (e.g., `Sunday` to `Saturday`) |
169+
| $N | ISO-8601 numeric representation of the day of the week (e.g., `1` for `Monday` to `7` for `Sunday`) |
170+
| $S | English ordinal suffix for the day of the month, 2 characters (e.g., `st`, `nd`, `rd`, `th`) |
171+
| $w | Numeric representation of the day of the week (e.g., `0` for `Sunday` to `6` for `Saturday`) |
172+
| $z | The day of the year (starting from 0) (e.g., 0 to 365) |
173+
| $W | ISO-8601 week number of year, weeks starting on Monday (e.g., `01` to `53`) |
174+
| $F | A full textual representation of a month (e.g., `January` to `December`) |
175+
| $m | Numeric representation of a month, with leading zeros (e.g., `01` to `12`) |
176+
| $M | A short textual representation of a month, three letters (e.g., `Jan` to `Dec`) |
177+
| $n | Numeric representation of a month, without leading zeros (e.g., `1` to `12`) |
178+
| $t | Number of days in the given month (e.g., `28` to `31`) |
179+
| $L | Whether it's a leap year (e.g., `1` for leap year, `0` otherwise) |
180+
| $o | ISO-8601 week-numbering year. This has the same value as Y, except that if the ISO week number (W) belongs to the previous or next year, that year is used instead (e.g., `1999` or `2003`) |
181+
| $y | A two-digit representation of a year (e.g., 99 or 03) |
182+
| $Y | A full numeric representation of a year, 4 digits (e.g., `1999` or `2003`) |
183+
| $a | Lowercase am or pm |
184+
| $A | Uppercase AM or PM |
185+
| $g | 12-hour format of an hour without leading zeros (e.g., `1` to `12`) |
186+
| $G | 24-hour format of an hour without leading zeros (e.g., `0` to `23`) |
187+
| $h | 12-hour format of an hour with leading zeros (e.g., `01` to `12`) |
188+
| $H | 24-hour format of an hour with leading zeros (e.g., `00` to `23`) |
189+
| $i | Minutes with leading zeros (e.g., `00` to `59`) |
190+
| $s | Seconds with leading zeros (e.g., `00` to `59`) |
191+
| $I | (capital 'i'): Whether or not the date is in daylight saving time (e.g., `1` for DST, `0` otherwise) |
192+
| $O | Difference to Greenwich time (GMT) in hours (e.g., `+0200`) |
193+
| $p | Difference to Greenwich time (GMT) with colon between hours and minutes (e.g., `+05:30`, `-04:00`) |
194+
| $t | Number of days in the given month (e.g., `28`, `29`, `30`, `31`) |
195+
| $r | RFC 2822 formatted date (e.g., `Thu, 21 Dec 2000 16:01:07 +0200`) |
196+
197+
160198
Format Options
161199
--------------
162200

0 commit comments

Comments
 (0)