Skip to content

Commit 4b0552a

Browse files
committed
chore: format code by prettier
1 parent 66658c1 commit 4b0552a

13 files changed

Lines changed: 176 additions & 146 deletions

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
permissions:
12-
contents: read
13-
id-token: write
12+
contents: read
13+
id-token: write
1414
steps:
1515
- name: Checkout repository
1616
uses: actions/checkout@v4

CODE_OF_CONDUCT.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ We are committed to making participation in this project a harassment-free exper
66

77
Examples of unacceptable behavior by participants include:
88

9-
* The use of sexualized language or imagery
10-
* Personal attacks
11-
* Trolling or insulting/derogatory comments
12-
* Public or private harassment
13-
* Publishing other's private information, such as physical or electronic addresses, without explicit permission
14-
* Submitting contributions or comments that you know to violate the intellectual property or privacy rights of others
15-
* Other unethical or unprofessional conduct
9+
- The use of sexualized language or imagery
10+
- Personal attacks
11+
- Trolling or insulting/derogatory comments
12+
- Public or private harassment
13+
- Publishing other's private information, such as physical or electronic addresses, without explicit permission
14+
- Submitting contributions or comments that you know to violate the intellectual property or privacy rights of others
15+
- Other unethical or unprofessional conduct
1616

1717
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
1818
By adopting this Code of Conduct, project maintainers commit themselves to fairly and consistently applying these principles to every aspect of managing this project. Project maintainers who do not follow or enforce the Code of Conduct may be permanently removed from the project team.

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
Thank you for considering a contribution to Date Time API! Pull requests, issues and comments are welcome. For pull requests, please:
44

5-
* Add tests for new features and bug fixes
6-
* Follow the existing style
7-
* Separate unrelated changes into multiple pull requests
5+
- Add tests for new features and bug fixes
6+
- Follow the existing style
7+
- Separate unrelated changes into multiple pull requests
88

99
See the existing issues for things to start contributing.
1010

@@ -14,5 +14,5 @@ Atlassian requires contributors to sign a Contributor License Agreement, known a
1414

1515
Prior to accepting your contributions we ask that you please follow the appropriate link below to digitally sign the CLA. The Corporate CLA is for those who are contributing as a member of an organization and the individual CLA is for those contributing as an individual.
1616

17-
* [CLA for corporate contributors](https://opensource.atlassian.com/corporate)
18-
* [CLA for individuals](https://opensource.atlassian.com/individual)
17+
- [CLA for corporate contributors](https://opensource.atlassian.com/corporate)
18+
- [CLA for individuals](https://opensource.atlassian.com/individual)

README.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ The Date Time API is a comprehensive library designed to simplify date and time
99
## Usage
1010

1111
```javascript
12-
import * as dateTime from '@atlassian/date-time';
12+
import * as dateTime from "@atlassian/date-time";
1313

1414
// Parse a date string
15-
const date = dateTime.parse('2024-01-01');
15+
const date = dateTime.parse("2024-01-01");
1616
console.log(date); // Outputs: "Mon Jan 01 2024 00:00:00 GMT+0000 (Coordinated Universal Time)"
1717

1818
// Get date pattern
19-
const pattern = dateTime.getDatePattern('en-US');
19+
const pattern = dateTime.getDatePattern("en-US");
2020
console.log(pattern); // Outputs: "mm/dd/yyyy"
2121

2222
// Validate a date string
23-
const isValid = dateTime.validate('2024-01-01');
23+
const isValid = dateTime.validate("2024-01-01");
2424
console.log(isValid); // Outputs: true
2525

2626
// Format a plain date
@@ -36,36 +36,31 @@ const plainDateTime = dateTime.formatPlainDateTime(new Date());
3636
console.log(plainDateTime); // Outputs: "2024-01-01T12:00:00"
3737

3838
// Format a numeric date
39-
const numericDate = dateTime.formatNumericDate(new Date(), 'en-US');
39+
const numericDate = dateTime.formatNumericDate(new Date(), "en-US");
4040
console.log(numericDate); // Outputs: "1/1/2024"
4141

4242
// Format a date
43-
const formattedDate = dateTime.formatDate(new Date(), 'en-US');
43+
const formattedDate = dateTime.formatDate(new Date(), "en-US");
4444
console.log(formattedDate); // Outputs: "Jan 1, 2024"
4545

4646
// Format a time
47-
const formattedTime = dateTime.formatTime(new Date(), 'en-US');
47+
const formattedTime = dateTime.formatTime(new Date(), "en-US");
4848
console.log(formattedTime); // Outputs: "12:00:00 PM"
4949

5050
// Format a date-time
51-
const formattedDateTime = dateTime.formatDateTime(new Date(), 'en-US');
51+
const formattedDateTime = dateTime.formatDateTime(new Date(), "en-US");
5252
console.log(formattedDateTime); // Outputs: "Jan 1, 2024, 12:00:00 PM"
5353

5454
// Format a date-time with options
55-
const formattedDateTimeWithOptions = dateTime.formatDateTimeByOptions({ second: undefined }, new Date(), 'en-US');
55+
const formattedDateTimeWithOptions = dateTime.formatDateTimeByOptions({ second: undefined }, new Date(), "en-US");
5656
console.log(formattedDateTimeWithOptions); // Outputs: "Jan 1, 2024, 12:00 PM"
5757

5858
// Format a duration
59-
const duration = dateTime.formatDuration(new Date(2024, 0, 1), new Date(2024, 0, 2), 'en-US');
59+
const duration = dateTime.formatDuration(new Date(2024, 0, 1), new Date(2024, 0, 2), "en-US");
6060
console.log(duration); // Outputs: "1 day 1 hour 1 minute 1 second"
6161

6262
// Format a duration with custom options
63-
const durationWithOptions = dateTime.formatDurationByOptions(
64-
{ unitDisplay: 'narrow' },
65-
new Date(2024, 0, 1),
66-
new Date(2024, 0, 2),
67-
'en-US'
68-
);
63+
const durationWithOptions = dateTime.formatDurationByOptions({ unitDisplay: "narrow" }, new Date(2024, 0, 1), new Date(2024, 0, 2), "en-US");
6964
console.log(durationWithOptions); // Outputs: "1d 1h 1m 1s"
7065
```
7166

eslint.config.mjs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@ import tseslint from "typescript-eslint";
55

66
export default defineConfig([
77
{ files: ["**/*.{js,mjs,cjs,ts}"] },
8-
{ files: ["**/*.{js,mjs,cjs,ts}"], languageOptions: { globals: {...globals.browser, ...globals.node} } },
9-
{ files: ["**/*.{js,mjs,cjs,ts}"], plugins: { js }, extends: ["js/recommended"] },
8+
{
9+
files: ["**/*.{js,mjs,cjs,ts}"],
10+
languageOptions: { globals: { ...globals.browser, ...globals.node } },
11+
},
12+
{
13+
files: ["**/*.{js,mjs,cjs,ts}"],
14+
plugins: { js },
15+
extends: ["js/recommended"],
16+
},
1017
tseslint.configs.recommended,
1118
globalIgnores([
1219
"build/**/*",
1320
"coverage/**/*",
14-
"dist/**/*",
21+
"dist/**/*",
1522
"node_modules/**/*",
16-
]),
23+
]),
1724
]);

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @type {import('ts-jest').JestConfigWithTsJest} */
22
module.exports = {
3-
preset: "ts-jest",
4-
testEnvironment: "node",
3+
preset: 'ts-jest',
4+
testEnvironment: 'node',
55
};

package-lock.json

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
"build:amd": "tsc --project tsconfig.amd.json",
1616
"build:cjs": "tsc --project tsconfig.cjs.json",
1717
"build:esm": "tsc --project tsconfig.esm.json",
18-
"format": "npm run format:lint",
18+
"format": "npm run format:lint && npm run format:prettier",
1919
"format:lint": "eslint --fix .",
20+
"format:prettier": "prettier --write .",
2021
"test": "npm run test:tsc && npm run test:lint && npm run test:jest -- --coverage",
2122
"test:tsc": "tsc --noEmit",
23+
"test:prettier": "prettier --check .",
2224
"test:lint": "eslint .",
2325
"test:jest": "jest",
2426
"prepublishOnly": "npm t && npm run build",
@@ -45,6 +47,7 @@
4547
"eslint": "^9.24.0",
4648
"globals": "^16.0.0",
4749
"jest": "^29.7.0",
50+
"prettier": "3.5.3",
4851
"ts-jest": "^29.2.5",
4952
"typescript": "^5.7.3",
5053
"typescript-eslint": "^8.29.0"

renovate.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3-
"extends": [
4-
"config:recommended"
5-
]
3+
"extends": ["config:recommended"]
64
}

src/global.d.ts

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* Represents the shape of a duration for use with Intl.DurationFormat.
43
* All fields are optional and represent their respective time units.
@@ -7,50 +6,50 @@
76
* https://github.com/microsoft/TypeScript/issues/60608
87
*/
98
export type Duration = {
10-
years?: number;
11-
months?: number;
12-
weeks?: number;
13-
days?: number;
14-
hours?: number;
15-
minutes?: number;
16-
seconds?: number;
17-
milliseconds?: number;
18-
microseconds?: number;
19-
nanoseconds?: number;
9+
years?: number;
10+
months?: number;
11+
weeks?: number;
12+
days?: number;
13+
hours?: number;
14+
minutes?: number;
15+
seconds?: number;
16+
milliseconds?: number;
17+
microseconds?: number;
18+
nanoseconds?: number;
2019
};
2120

2221
type DurationUnits = keyof Duration;
2322

2423
export type DurationOptionUnits = {
25-
[K in DurationUnits as `${K}`]?: "long" | "short" | "narrow";
24+
[K in DurationUnits as `${K}`]?: 'long' | 'short' | 'narrow';
2625
} & {
27-
[K in DurationUnits as `${K}Display`]?: "auto" | "always";
26+
[K in DurationUnits as `${K}Display`]?: 'auto' | 'always';
2827
};
2928

3029
declare global {
31-
namespace Intl {
32-
interface DurationFormatOptions extends DurationOptionUnits {
33-
style?: "long" | "short" | "narrow" | "digital";
34-
fractionalDigits?: number;
35-
}
30+
namespace Intl {
31+
interface DurationFormatOptions extends DurationOptionUnits {
32+
style?: 'long' | 'short' | 'narrow' | 'digital';
33+
fractionalDigits?: number;
34+
}
3635

37-
const DurationFormat: {
38-
new (locales?: string | string[], options?: DurationFormatOptions): DurationFormat;
39-
supportedLocalesOf(locales: string | string[]): string[];
40-
};
36+
const DurationFormat: {
37+
new (locales?: string | string[], options?: DurationFormatOptions): DurationFormat;
38+
supportedLocalesOf(locales: string | string[]): string[];
39+
};
4140

42-
interface DurationFormat {
43-
format(duration: Duration): string;
44-
formatToParts(duration: Duration): Array<{ type: string; value: string }>;
45-
resolvedOptions(): {
46-
locale: string;
47-
numberingSystem: string;
48-
style: "long" | "short" | "narrow" | "digital";
49-
[K in DurationUnits as `${K}`]?: "long" | "short" | "narrow";
50-
[K in DurationUnits as `${K}Display`]?: "auto" | "always";
51-
};
41+
interface DurationFormat {
42+
format(duration: Duration): string;
43+
formatToParts(duration: Duration): Array<{ type: string; value: string }>;
44+
resolvedOptions(): {
45+
locale: string;
46+
numberingSystem: string;
47+
style: 'long' | 'short' | 'narrow' | 'digital';
48+
[(K in DurationUnits) as `${K}`]?: 'long' | 'short' | 'narrow';
49+
[(K in DurationUnits) as `${K}Display`]?: 'auto' | 'always';
50+
};
51+
}
5252
}
53-
}
5453
}
5554

5655
export {};

0 commit comments

Comments
 (0)