Skip to content

Commit fe5d4fa

Browse files
Merge pull request #98 from knowledgecode/develop
Add logo to README header
2 parents 0f9d770 + a989f43 commit fe5d4fa

File tree

2 files changed

+46
-42
lines changed

2 files changed

+46
-42
lines changed

README.md

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
# date-and-time
1+
<div align="center">
2+
<img src="https://raw.githubusercontent.com/knowledgecode/date-and-time/refs/heads/master/logo.png" alt="date-and-time" width="256">
3+
</div>
4+
5+
<div align="center">
26

37
[![CI](https://github.com/knowledgecode/date-and-time/actions/workflows/test.yml/badge.svg)](https://github.com/knowledgecode/date-and-time/actions/workflows/test.yml)
4-
[![Coverage](./.github/badges/coverage.svg)](https://github.com/knowledgecode/date-and-time/actions/workflows/test.yml)
8+
[![Coverage](https://raw.githubusercontent.com/knowledgecode/date-and-time/refs/heads/master/.github/badges/coverage.svg)](https://github.com/knowledgecode/date-and-time/actions/workflows/test.yml)
59
[![npm](https://img.shields.io/npm/v/date-and-time)](https://www.npmjs.com/package/date-and-time)
610

7-
The simplest and most user-friendly date and time manipulation library
11+
</div>
812

913
## Install
1014

@@ -38,11 +42,11 @@ Version `4.x` has been completely rewritten in TypeScript and some features from
3842
- Tree shaking is now supported
3943
- Supports `ES2021` and no longer supports older browsers
4044

41-
For details, please refer to [MIGRATION.md](docs/MIGRATION.md).
45+
For details, please refer to [MIGRATION.md](https://github.com/knowledgecode/date-and-time/blob/master/docs/MIGRATION.md).
4246

4347
## API
4448

45-
## format(dateObj, arg[, options])
49+
### format(dateObj, arg[, options])
4650

4751
<details>
4852
<summary>Formats a Date object according to the specified format string.</summary>
@@ -111,7 +115,7 @@ The tokens available for use in the format string specified as the second argume
111115
| Z | Timezone offset | +0100, -0800 |
112116
| ZZ | Timezone offset with colon | +01:00, -08:00 |
113117

114-
Additionally, by importing plugins, you can use the following tokens. For details, please refer to [PLUGINS.md](docs/PLUGINS.md).
118+
Additionally, by importing plugins, you can use the following tokens. For details, please refer to [PLUGINS.md](https://github.com/knowledgecode/date-and-time/blob/master/docs/PLUGINS.md).
115119

116120
| Token | Meaning | Output Examples |
117121
|:---------|:--------------------------------------------|:----------------------|
@@ -265,9 +269,9 @@ format(now, 'dddd, D [de] MMMM [de] YYYY, h:mm:ss.SSS aa [GMT]ZZ', { locale: es
265269
</details>
266270
</details>
267271

268-
### Notes
272+
#### Notes
269273

270-
<details>
274+
<details open>
271275
<summary><strong>Comments</strong></summary>
272276

273277
Parts of the format string enclosed in brackets are output as-is, regardless of whether they are valid tokens.
@@ -279,7 +283,7 @@ format(new Date(), '[DD-[MM]-YYYY]'); // => 'DD-[MM]-YYYY'
279283

280284
</details>
281285

282-
<details>
286+
<details open>
283287
<summary><strong>Output as UTC timezone</strong></summary>
284288

285289
To output date and time as UTC timezone, specify the string `UTC` in the `timeZone` property of `FormatterOptions`.
@@ -295,7 +299,7 @@ format(new Date(), 'hh:mm A [GMT]Z', { timeZone: 'UTC' });
295299
</details>
296300
</details>
297301

298-
## parse(dateString, arg[, options])
302+
### parse(dateString, arg[, options])
299303

300304
<details>
301305
<summary>Parses a date string according to the specified format.</summary>
@@ -364,7 +368,7 @@ The tokens available for use in the format string specified as the second argume
364368
| Z | Timezone offset | +0100, -0800 |
365369
| ZZ | Timezone offset with colon | +01:00, -08:00 |
366370

367-
Additionally, by importing plugins, you can use the following tokens. For details, please refer to [PLUGINS.md](docs/PLUGINS.md).
371+
Additionally, by importing plugins, you can use the following tokens. For details, please refer to [PLUGINS.md](https://github.com/knowledgecode/date-and-time/blob/master/docs/PLUGINS.md).
368372

369373
| Token | Meaning | Input Examples |
370374
|:----------|:-------------------------------------------|:---------------------|
@@ -555,9 +559,9 @@ parse(
555559
</details>
556560
</details>
557561

558-
### Notes
562+
#### Notes
559563

560-
<details>
564+
<details open>
561565
<summary><strong>When parsing fails</strong></summary>
562566

563567
If this function fails to parse, it will return `Invalid Date`. Notice that the `Invalid Date` is a Date object, not `NaN` or `null`. You can tell whether the Date object is invalid as follows:
@@ -572,7 +576,7 @@ if (isNaN(today.getTime())) {
572576

573577
</details>
574578

575-
<details>
579+
<details open>
576580
<summary><strong>Input as UTC timezone</strong></summary>
577581

578582
If the `dateString` does not contain a timezone offset and the `timeZone` property of the third argument is not specified, this function considers the `dateString` to be in the local timezone. If you want to process a `dateString` without a timezone offset as UTC timezone, set the string `UTC` to the `timeZone` property in the third argument. Note that the timezone offset contained in the `dateString` takes precedence over the `timeZone` property of the third argument.
@@ -590,7 +594,7 @@ parse('11:14:05 PM', 'hh:mm:ss A', { timeZone: 'UTC' });
590594

591595
</details>
592596

593-
<details>
597+
<details open>
594598
<summary><strong>Default Date Time</strong></summary>
595599

596600
Default date is `January 1, 1970`, time is `00:00:00.000`. Any date/time components not specified in the input string will be filled with these default values.
@@ -605,7 +609,7 @@ parse('Feb 2000', 'MMM YYYY');
605609

606610
</details>
607611

608-
<details>
612+
<details open>
609613
<summary><strong>Max Date / Min Date</strong></summary>
610614

611615
The parsable maximum date is `December 31, 9999`, and the minimum date is `January 1, 0001`.
@@ -626,7 +630,7 @@ parse('Jan 1 0000', 'MMM D YYYY');
626630

627631
</details>
628632

629-
<details>
633+
<details open>
630634
<summary><strong>12-hour notation and Meridiem</strong></summary>
631635

632636
If you use the `hh` or `h` (12-hour) token, use it together with the `A` (meridiem) token to get the correct value.
@@ -641,7 +645,7 @@ parse('11:14:05 PM', 'hh:mm:ss A');
641645

642646
</details>
643647

644-
<details>
648+
<details open>
645649
<summary><strong>Token invalidation</strong></summary>
646650

647651
Any part of the given format string that you do not want to be recognized as a token should be enclosed in square brackets. They are considered comments and will not be parsed.
@@ -656,7 +660,7 @@ parse('12 hours 34 minutes', 'HH [hours] mm [minutes]');
656660

657661
</details>
658662

659-
<details>
663+
<details open>
660664
<summary><strong>Wildcard</strong></summary>
661665

662666
Whitespace acts as a wildcard token. This token will skip parsing the corresponding parts of the date and time strings. This behavior is similar to enclosing part of a format string in square brackets (Token invalidation), but with the flexibility that the contents do not have to match exactly - only the character count needs to match between the format string and input string.
@@ -672,7 +676,7 @@ parse('2015/01/02 11:14:05', 'YYYY/MM/DD ');
672676

673677
</details>
674678

675-
<details>
679+
<details open>
676680
<summary><strong>Ellipsis</strong></summary>
677681

678682
`...` token ignores subsequent corresponding date and time strings. Use this token only at the end of a format string. The above example can also be written like this:
@@ -685,7 +689,7 @@ parse('2015/01/02 11:14:05', 'YYYY/MM/DD...');
685689
</details>
686690
</details>
687691

688-
## compile(formatString)
692+
### compile(formatString)
689693

690694
<details>
691695
<summary>Compiles a format string into a tokenized array for efficient parsing and formatting.</summary>
@@ -711,7 +715,7 @@ format(new Date(), pattern);
711715

712716
</details>
713717

714-
## preparse(dateString, arg[, options])
718+
### preparse(dateString, arg[, options])
715719

716720
<details>
717721
<summary>Preparses a date string according to the specified pattern.</summary>
@@ -749,7 +753,7 @@ This date structure provides a parsing result. You will be able to tell from it
749753

750754
</details>
751755

752-
## isValid(dateString, arg[, options])
756+
### isValid(dateString, arg[, options])
753757

754758
<details>
755759
<summary>Validates whether a date string is valid according to the specified format.</summary>
@@ -773,7 +777,7 @@ For details about `ParserOptions`, refer to the `parse` function section.
773777

774778
</details>
775779

776-
## transform(dateString, arg1, arg2[, options1[, options2]])
780+
### transform(dateString, arg1, arg2[, options1[, options2]])
777781

778782
<details>
779783
<summary>Transforms a date string from one format to another.</summary>
@@ -821,7 +825,7 @@ For details about `ParserOptions`, refer to the `parse` function section. For de
821825

822826
</details>
823827

824-
## addYears(dateObj, years[, timeZone])
828+
### addYears(dateObj, years[, timeZone])
825829

826830
<details>
827831
<summary>Adds the specified number of years to a Date object.</summary>
@@ -856,7 +860,7 @@ const back = addYears(next, -1, 'UTC'); // => Feb 28 2020 (not the origi
856860

857861
</details>
858862

859-
## addMonths(dateObj, months[, timeZone])
863+
### addMonths(dateObj, months[, timeZone])
860864

861865
<details>
862866
<summary>Adds the specified number of months to a Date object.</summary>
@@ -891,7 +895,7 @@ const feb = addMonths(apr, -2, 'UTC'); // => Feb 28 2023
891895

892896
</details>
893897

894-
## addDays(dateObj, days[, timeZone])
898+
### addDays(dateObj, days[, timeZone])
895899

896900
<details>
897901
<summary>Adds the specified number of days to a Date object.</summary>
@@ -918,7 +922,7 @@ addDays(now, -1, Los_Angeles); // => Mar 10 2024 01:00:00 GMT-08:00
918922

919923
</details>
920924

921-
## addHours(dateObj, hours)
925+
### addHours(dateObj, hours)
922926

923927
<details>
924928
<summary>Adds the specified number of hours to a Date object.</summary>
@@ -940,7 +944,7 @@ addHours(now, -1); // => Jul 23 2025 23:00:00
940944

941945
</details>
942946

943-
## addMinutes(dateObj, minutes)
947+
### addMinutes(dateObj, minutes)
944948

945949
<details>
946950
<summary>Adds the specified number of minutes to a Date object.</summary>
@@ -962,7 +966,7 @@ addMinutes(now, 2); // => Jul 24 2025 00:02:00
962966

963967
</details>
964968

965-
## addSeconds(dateObj, seconds)
969+
### addSeconds(dateObj, seconds)
966970

967971
<details>
968972
<summary>Adds the specified number of seconds to a Date object.</summary>
@@ -984,7 +988,7 @@ addSeconds(now, -3); // => Jul 23 2025 23:59:57
984988

985989
</details>
986990

987-
## addMilliseconds(dateObj, milliseconds)
991+
### addMilliseconds(dateObj, milliseconds)
988992

989993
<details>
990994
<summary>Adds the specified number of milliseconds to a Date object.</summary>
@@ -1006,7 +1010,7 @@ addMilliseconds(now, 123); // => Jul 24 2025 00:00:00.123
10061010

10071011
</details>
10081012

1009-
## subtract(from, to)
1013+
### subtract(from, to)
10101014

10111015
<details>
10121016
<summary>Calculates the difference between two dates.</summary>
@@ -1037,7 +1041,7 @@ duration.toMicroseconds().value; // => 97445006000
10371041
duration.toNanoseconds().value; // => 97445006000000
10381042
```
10391043

1040-
### Duration
1044+
#### Duration
10411045

10421046
The `Duration` object can be directly created not only as a return value of the `subtract` function, but also by passing any numeric value (milliseconds) as a constructor argument.
10431047

@@ -1175,13 +1179,13 @@ duration.toNanoseconds().toParts();
11751179

11761180
</details>
11771181

1178-
### DurationDescriptor
1182+
#### DurationDescriptor
11791183

1180-
#### value
1184+
##### value
11811185

11821186
The value of the duration in the respective unit.
11831187

1184-
#### format(formatString[, numeral])
1188+
##### format(formatString[, numeral])
11851189

11861190
<details>
11871191
<summary>Formats the duration according to the provided format string.</summary>
@@ -1210,7 +1214,7 @@ What makes the format string in `DurationDescriptor` different from others is th
12101214

12111215
</details>
12121216

1213-
#### toParts()
1217+
##### toParts()
12141218

12151219
<details>
12161220
<summary>Converts the duration to an object containing the parts of the duration in the respective unit.</summary>
@@ -1229,9 +1233,9 @@ What makes the format string in `DurationDescriptor` different from others is th
12291233

12301234
</details>
12311235

1232-
### Notes
1236+
#### Notes
12331237

1234-
<details>
1238+
<details open>
12351239
<summary><strong>Negative Duration</strong></summary>
12361240

12371241
When the `value` becomes negative, there are slight differences in the output results of the `format` method and the `toParts` method. In the `format` method, only the largest unit in the `DurationDescriptor`, for example, only the `D` token in the case of a `DurationDescriptor` obtained by the `toDays` method, gets a minus sign, while in the `toParts` method, all units get a minus sign.
@@ -1249,7 +1253,7 @@ duration.toDays().toParts();
12491253

12501254
</details>
12511255

1252-
<details>
1256+
<details open>
12531257
<summary><strong>Negative Zero</strong></summary>
12541258

12551259
The `format` method may output `-0`. For example, when the value of a `DurationDescriptor` obtained by the `toDays` method is a negative decimal less than 1, using the `D` token in the `format` method outputs `-0`.
@@ -1268,7 +1272,7 @@ duration.toDays().toParts();
12681272
</details>
12691273
</details>
12701274

1271-
## isLeapYear(year)
1275+
### isLeapYear(year)
12721276

12731277
<details>
12741278
<summary>Determines if the specified year is a leap year.</summary>
@@ -1286,7 +1290,7 @@ isLeapYear(2012); // => true
12861290

12871291
</details>
12881292

1289-
## isSameDay(date1, date2)
1293+
### isSameDay(date1, date2)
12901294

12911295
<details>
12921296
<summary>Determines if two dates represent the same calendar day.</summary>

logo.png

222 KB
Loading

0 commit comments

Comments
 (0)