Skip to content

Commit 4142ef1

Browse files
Merge pull request #155 from TalhaAwan/master
change DDD abbreviation for yesterday, today and tomorrow
2 parents 111e2f2 + 4f1aba0 commit 4142ef1

3 files changed

Lines changed: 13 additions & 13 deletions

File tree

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ dateFormat(now, "N");
8282
| `d` | Day of the month as digits; no leading zero for single-digit days. |
8383
| `dd` | Day of the month as digits; leading zero for single-digit days. |
8484
| `ddd` | Day of the week as a three-letter abbreviation. |
85-
| `DDD` | "Yes", "Tod" or "Tom" if date lies within these three days. Else fall back to ddd. |
85+
| `DDD` | "Ysd", "Tdy" or "Tmw" if date lies within these three days. Else fall back to ddd. |
8686
| `dddd` | Day of the week as its full name. |
8787
| `DDDD` | "Yesterday", "Today" or "Tomorrow" if date lies within these three days. Else fall back to dddd. |
8888
| `m` | Month as digits; no leading zero for single-digit months. |

src/dateformat.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,13 +249,13 @@
249249
const tomorrow_y = () => tomorrow[_ + 'FullYear']();
250250

251251
if (today_y() === y && today_m() === m && today_D() === D) {
252-
return short ? 'Tod' : 'Today';
252+
return short ? 'Tdy' : 'Today';
253253
}
254254
else if (yesterday_y() === y && yesterday_m() === m && yesterday_D() === D) {
255-
return short ? 'Yes' : 'Yesterday';
255+
return short ? 'Ysd' : 'Yesterday';
256256
}
257257
else if (tomorrow_y() === y && tomorrow_m() === m && tomorrow_D() === D) {
258-
return short ? 'Tom' : 'Tomorrow';
258+
return short ? 'Tmw' : 'Tomorrow';
259259
}
260260
return dayName;
261261
};

test/test_threedays.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const dateFormat = require('./../lib/dateformat');
44

55
const dayNamesShort = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
66
const dayNamesLong = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
7-
const threeDays = ['Yesterday', 'Today', 'Tomorrow', 'Yes', 'Tod', 'Tom'];
7+
const threeDays = ['Yesterday', 'Today', 'Tomorrow', 'Ysd', 'Tdy', 'Tmw'];
88

99
describe('threeDays', function () {
1010
let date, DDD, DDDD;
@@ -17,20 +17,20 @@ describe('threeDays', function () {
1717
assert.strictEqual(DDDD, "Yesterday");
1818
done();
1919
});
20-
it('should return "Yes" (Today - 1 day)', function (done) {
20+
it('should return "Ysd" (Today - 1 day)', function (done) {
2121
date.setDate(date.getDate() - 1);
2222
DDD = dateFormat(date, 'DDD');
23-
assert.strictEqual(DDD, "Yes");
23+
assert.strictEqual(DDD, "Ysd");
2424
done();
2525
});
2626
it('should return "Today" (Today)', function (done) {
2727
DDDD = dateFormat(date, 'DDDD');
2828
assert.strictEqual(DDDD, "Today");
2929
done();
3030
});
31-
it('should return "Tod" (Today)', function (done) {
31+
it('should return "Tdy" (Today)', function (done) {
3232
DDD = dateFormat(date, 'DDD');
33-
assert.strictEqual(DDD, "Tod");
33+
assert.strictEqual(DDD, "Tdy");
3434
done();
3535
});
3636
it('should return "Tomorrow" (Today + 1 day)', function (done) {
@@ -39,21 +39,21 @@ describe('threeDays', function () {
3939
assert.strictEqual(DDDD, "Tomorrow");
4040
done();
4141
});
42-
it('should return "Tom" (Today + 1 day)', function (done) {
42+
it('should return "Tmw" (Today + 1 day)', function (done) {
4343
date.setDate(date.getDate() + 1);
4444
DDD = dateFormat(date, 'DDD');
45-
assert.strictEqual(DDD, "Tom");
45+
assert.strictEqual(DDD, "Tmw");
4646
done();
4747
});
48-
it('should not return "Yesterday", "Today", "Tomorrow", "Yes", "Tod", or "Tom" (Today - 2 days)', function (done) {
48+
it('should not return "Yesterday", "Today", "Tomorrow", "Ysd", "Tdy", or "Tmw" (Today - 2 days)', function (done) {
4949
date.setDate(date.getDate() - 2);
5050
DDD = dateFormat(date, 'DDD');
5151
DDDD = dateFormat(date, 'DDDD');
5252
assert.strictEqual(threeDays.indexOf(DDD), -1);
5353
assert.strictEqual(threeDays.indexOf(DDDD), -1);
5454
done();
5555
});
56-
it('should not return "Yesterday", "Today" or "Tomorrow", "Yes", "Tod", or "Tom" (Today + 2 days)', function (done) {
56+
it('should not return "Yesterday", "Today" or "Tomorrow", "Ysd", "Tdy", or "Tmw" (Today + 2 days)', function (done) {
5757
date.setDate(date.getDate() + 2);
5858
DDD = dateFormat(date, 'DDD');
5959
DDDD = dateFormat(date, 'DDDD');

0 commit comments

Comments
 (0)