Skip to content

Commit cd1ac2b

Browse files
committed
docs: improve locales, timezones, homepage, and fix Aside syntax
- Add intro paragraphs and usage examples to locales.md and timezones.md - Promote locale list items from - bullets to ### headings for TOC support - Fix homepage hero to use Astro local image asset instead of raw HTML - Fix action and API links to remove trailing slash - Replace VitePress :::tip[...] syntax with Starlight <Aside> component
1 parent bbef3bd commit cd1ac2b

4 files changed

Lines changed: 83 additions & 54 deletions

File tree

docs/guide/installation.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Installation
33
---
44

5-
import { Tabs, TabItem } from '@astrojs/starlight/components';
5+
import { Aside, Tabs, TabItem } from '@astrojs/starlight/components';
66

77
Get started with date-and-time in your project using your preferred package manager.
88

@@ -144,9 +144,9 @@ For browser-only projects, you can use date-and-time directly from a CDN:
144144

145145
## Bundle Size
146146

147-
:::tip[Tree Shaking Benefits]
148-
date-and-time is built with tree-shaking in mind. You only bundle the functions and locales you actually use, resulting in optimal bundle sizes. Modern bundlers like Webpack 5, Rollup, and Vite automatically eliminate unused code, ensuring your application stays lightweight.
149-
:::
147+
<Aside type="tip" title="Tree Shaking Benefits">
148+
date-and-time is built with tree-shaking in mind. You only bundle the functions and locales you actually use, resulting in optimal bundle sizes. Modern bundlers like Webpack 5, Rollup, and Vite automatically eliminate unused code, ensuring your application stays lightweight.
149+
</Aside>
150150

151151
## Verification
152152

docs/index.mdx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ title: date-and-time
33
description: The simplest, most intuitive date and time library
44
template: splash
55
hero:
6-
title: date-and-time
7-
tagline: The simplest, most intuitive date and time library. Modern TypeScript library for date manipulation with full ES Modules support.
6+
title: The simplest, most intuitive date and time library
7+
tagline: Modern TypeScript library for date manipulation with full ES Modules support.
88
image:
9-
html: '<img src="/date-and-time/logo.png" alt="date-and-time" style="max-height:16rem;width:auto;" />'
9+
alt: date-and-time
10+
file: ./assets/logo.png
1011
actions:
1112
- text: Get Started
12-
link: /date-and-time/guide/
13+
link: /date-and-time/guide
1314
icon: right-arrow
1415
variant: primary
1516
- text: API Reference
16-
link: /date-and-time/api/
17+
link: /date-and-time/api
1718
variant: minimal
1819
- text: View on GitHub
1920
link: https://github.com/knowledgecode/date-and-time

docs/locales.md

Lines changed: 60 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,250 +1,267 @@
11
---
2-
title: Supported Locales
2+
title: Locales
33
---
44

5-
# Supported Locales
5+
Locales customize the language-specific strings used in date formatting and parsing — month names, day-of-week names, and AM/PM indicators. By default, the library uses English (`en`). To use another language, import the corresponding locale module and pass it as the `locale` option.
66

7-
- ar (Arabic)
7+
```typescript
8+
import { format, parse } from 'date-and-time';
9+
import es from 'date-and-time/locales/es';
10+
11+
const date = new Date('2025-08-23T12:00:00');
12+
13+
format(date, 'MMMM D, YYYY', { locale: es });
14+
// => agosto 23, 2025
15+
16+
format(date, 'ddd, D MMM', { locale: es });
17+
// => sáb, 23 ago
18+
```
19+
20+
## Supported Locales
21+
22+
The following 41 locales are available:
23+
24+
### ar (Arabic)
825

926
```typescript
1027
import ar from 'date-and-time/locales/ar';
1128
```
1229

13-
- az (Azerbaijani)
30+
### az (Azerbaijani)
1431

1532
```typescript
1633
import az from 'date-and-time/locales/az';
1734
```
1835

19-
- bn (Bengali)
36+
### bn (Bengali)
2037

2138
```typescript
2239
import bn from 'date-and-time/locales/bn';
2340
```
2441

25-
- cs (Czech)
42+
### cs (Czech)
2643

2744
```typescript
2845
import cs from 'date-and-time/locales/cs';
2946
```
3047

31-
- da (Danish)
48+
### da (Danish)
3249

3350
```typescript
3451
import da from 'date-and-time/locales/da';
3552
```
3653

37-
- de (German)
54+
### de (German)
3855

3956
```typescript
4057
import de from 'date-and-time/locales/de';
4158
```
4259

43-
- el (Greek)
60+
### el (Greek)
4461

4562
```typescript
4663
import el from 'date-and-time/locales/el';
4764
```
4865

49-
- en (English)
66+
### en (English)
5067

5168
```typescript
5269
import en from 'date-and-time/locales/en';
5370
```
5471

55-
- es (Spanish)
72+
### es (Spanish)
5673

5774
```typescript
5875
import es from 'date-and-time/locales/es';
5976
```
6077

61-
- fa (Persian)
78+
### fa (Persian)
6279

6380
```typescript
6481
import fa from 'date-and-time/locales/fa';
6582
```
6683

67-
- fi (Finnish)
84+
### fi (Finnish)
6885

6986
```typescript
7087
import fi from 'date-and-time/locales/fi';
7188
```
7289

73-
- fr (French)
90+
### fr (French)
7491

7592
```typescript
7693
import fr from 'date-and-time/locales/fr';
7794
```
7895

79-
- he (Hebrew)
96+
### he (Hebrew)
8097

8198
```typescript
8299
import he from 'date-and-time/locales/he';
83100
```
84101

85-
- hi (Hindi)
102+
### hi (Hindi)
86103

87104
```typescript
88105
import hi from 'date-and-time/locales/hi';
89106
```
90107

91-
- hu (Hungarian)
108+
### hu (Hungarian)
92109

93110
```typescript
94111
import hu from 'date-and-time/locales/hu';
95112
```
96113

97-
- id (Indonesian)
114+
### id (Indonesian)
98115

99116
```typescript
100117
import id from 'date-and-time/locales/id';
101118
```
102119

103-
- it (Italian)
120+
### it (Italian)
104121

105122
```typescript
106123
import it from 'date-and-time/locales/it';
107124
```
108125

109-
- ja (Japanese)
126+
### ja (Japanese)
110127

111128
```typescript
112129
import ja from 'date-and-time/locales/ja';
113130
```
114131

115-
- ko (Korean)
132+
### ko (Korean)
116133

117134
```typescript
118135
import ko from 'date-and-time/locales/ko';
119136
```
120137

121-
- ms (Malay)
138+
### ms (Malay)
122139

123140
```typescript
124141
import ms from 'date-and-time/locales/ms';
125142
```
126143

127-
- my (Burmese)
144+
### my (Burmese)
128145

129146
```typescript
130147
import my from 'date-and-time/locales/my';
131148
```
132149

133-
- nl (Dutch)
150+
### nl (Dutch)
134151

135152
```typescript
136153
import nl from 'date-and-time/locales/nl';
137154
```
138155

139-
- no (Norwegian)
156+
### no (Norwegian)
140157

141158
```typescript
142159
import no from 'date-and-time/locales/no';
143160
```
144161

145-
- pl (Polish)
162+
### pl (Polish)
146163

147164
```typescript
148165
import pl from 'date-and-time/locales/pl';
149166
```
150167

151-
- pt-BR (Brazilian Portuguese)
168+
### pt-BR (Brazilian Portuguese)
152169

153170
```typescript
154171
import ptBR from 'date-and-time/locales/pt-BR';
155172
```
156173

157-
- pt-PT (European Portuguese)
174+
### pt-PT (European Portuguese)
158175

159176
```typescript
160177
import ptPT from 'date-and-time/locales/pt-PT';
161178
```
162179

163-
- ro (Romanian)
180+
### ro (Romanian)
164181

165182
```typescript
166183
import ro from 'date-and-time/locales/ro';
167184
```
168185

169-
- ru (Russian)
186+
### ru (Russian)
170187

171188
```typescript
172189
import ru from 'date-and-time/locales/ru';
173190
```
174191

175-
- rw (Kinyarwanda)
192+
### rw (Kinyarwanda)
176193

177194
```typescript
178195
import rw from 'date-and-time/locales/rw';
179196
```
180197

181-
- sr-Cyrl (Serbian Cyrillic)
198+
### sr-Cyrl (Serbian Cyrillic)
182199

183200
```typescript
184201
import srCyrl from 'date-and-time/locales/sr-Cyrl';
185202
```
186203

187-
- sr-Latn (Serbian Latin)
204+
### sr-Latn (Serbian Latin)
188205

189206
```typescript
190207
import srLatn from 'date-and-time/locales/sr-Latn';
191208
```
192209

193-
- sv (Swedish)
210+
### sv (Swedish)
194211

195212
```typescript
196213
import sv from 'date-and-time/locales/sv';
197214
```
198215

199-
- ta (Tamil)
216+
### ta (Tamil)
200217

201218
```typescript
202219
import ta from 'date-and-time/locales/ta';
203220
```
204221

205-
- th (Thai)
222+
### th (Thai)
206223

207224
```typescript
208225
import th from 'date-and-time/locales/th';
209226
```
210227

211-
- tr (Turkish)
228+
### tr (Turkish)
212229

213230
```typescript
214231
import tr from 'date-and-time/locales/tr';
215232
```
216233

217-
- uk (Ukrainian)
234+
### uk (Ukrainian)
218235

219236
```typescript
220237
import uk from 'date-and-time/locales/uk';
221238
```
222239

223-
- uz-Cyrl (Uzbek Cyrillic)
240+
### uz-Cyrl (Uzbek Cyrillic)
224241

225242
```typescript
226243
import uzCyrl from 'date-and-time/locales/uz-Cyrl';
227244
```
228245

229-
- uz-Latn (Uzbek Latin)
246+
### uz-Latn (Uzbek Latin)
230247

231248
```typescript
232249
import uzLatn from 'date-and-time/locales/uz-Latn';
233250
```
234251

235-
- vi (Vietnamese)
252+
### vi (Vietnamese)
236253

237254
```typescript
238255
import vi from 'date-and-time/locales/vi';
239256
```
240257

241-
- zh-Hans (Simplified Chinese)
258+
### zh-Hans (Simplified Chinese)
242259

243260
```typescript
244261
import zhHans from 'date-and-time/locales/zh-Hans';
245262
```
246263

247-
- zh-Hant (Traditional Chinese)
264+
### zh-Hant (Traditional Chinese)
248265

249266
```typescript
250267
import zhHant from 'date-and-time/locales/zh-Hant';

docs/timezones.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
---
2-
title: Supported Timezones
2+
title: Timezones
33
---
44

5-
# Supported Timezones
5+
Timezone support lets you format and parse dates in any timezone, regardless of the local system timezone. Pass an IANA timezone name string as the `timeZone` option to any function that accepts it — no additional imports are needed for the recommended approach.
6+
7+
```typescript
8+
import { format } from 'date-and-time';
9+
10+
const date = new Date();
11+
12+
format(date, 'YYYY-MM-DD HH:mm:ss', { timeZone: 'Asia/Tokyo' });
13+
// => 2025-08-23 23:30:45
14+
```
615

716
## Import Methods
817

@@ -69,6 +78,8 @@ format(date, 'YYYY-MM-DD HH:mm:ss', { timeZone: New_York });
6978

7079
## Regions
7180

81+
The timezones listed below are confirmed to work — since this library internally relies on the `Intl` API, other timezones supported by your runtime may also work.
82+
7283
1. [Africa](#africa)
7384
2. [America](#america)
7485
3. [Antarctica](#antarctica)

0 commit comments

Comments
 (0)