Commit eb95c5a 1 parent 3b6f1e3 commit eb95c5a Copy full SHA for eb95c5a
File tree 4 files changed +19
-11
lines changed
4 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,15 @@ import type { Temporal } from "../types.js";
5
5
* @param dt datetime object which includes date and time info
6
6
* @returns Temporal object which represents the end of the day
7
7
*/
8
- export function endOfDay ( dt : Temporal . PlainDateTime ) : Temporal . PlainDateTime {
8
+ export function endOfDay < DateTime extends Temporal . PlainDateTime > (
9
+ dt : DateTime ,
10
+ ) : DateTime {
9
11
return dt . with ( {
10
12
hour : 23 ,
11
13
minute : 59 ,
12
14
second : 59 ,
13
15
millisecond : 999 ,
14
16
microsecond : 999 ,
15
17
nanosecond : 999 ,
16
- } ) ;
18
+ } ) as DateTime ;
17
19
}
Original file line number Diff line number Diff line change @@ -8,9 +8,11 @@ import { fromModifiedJulianDate } from "./fromModifiedJulianDate.js";
8
8
* @param Instant `Temporal.Instant` class
9
9
* @returns `Temporal.Instant` which corresponds to the given julian date
10
10
*/
11
- export function fromJulianDate (
11
+ export function fromJulianDate <
12
+ InstantClassType extends typeof Temporal . Instant ,
13
+ > (
12
14
julianDate : number ,
13
- Instant : typeof Temporal . Instant ,
14
- ) : Temporal . Instant {
15
+ Instant : InstantClassType ,
16
+ ) : InstanceType < InstantClassType > {
15
17
return fromModifiedJulianDate ( julianDate - 2400000.5 , Instant ) ;
16
18
}
Original file line number Diff line number Diff line change @@ -7,16 +7,18 @@ import type { Temporal } from "../types.js";
7
7
* @param Instant `Temporal.Instant` class
8
8
* @returns `Temporal.Instant` which corresponds to the given modified julian date
9
9
*/
10
- export function fromModifiedJulianDate (
10
+ export function fromModifiedJulianDate <
11
+ InstantClassType extends typeof Temporal . Instant ,
12
+ > (
11
13
modifiedJulianDate : number ,
12
- Instant : typeof Temporal . Instant ,
13
- ) : Temporal . Instant {
14
+ Instant : InstantClassType ,
15
+ ) : InstanceType < InstantClassType > {
14
16
const modifiedJulianDayInt = Math . floor ( modifiedJulianDate ) ;
15
17
const nanoseconds = Math . floor (
16
18
( modifiedJulianDate - modifiedJulianDayInt ) * 8.64e13 ,
17
19
) ;
18
20
return Instant . from ( "1858-11-17T00:00:00Z" ) . add ( {
19
21
hours : modifiedJulianDayInt * 24 ,
20
22
nanoseconds,
21
- } ) ;
23
+ } ) as InstanceType < InstantClassType > ;
22
24
}
Original file line number Diff line number Diff line change @@ -5,13 +5,15 @@ import type { Temporal } from "../types.js";
5
5
* @param dt datetime object which includes date and time info
6
6
* @returns Temporal object which represents the start of a day
7
7
*/
8
- export function startOfDay ( dt : Temporal . PlainDateTime ) : Temporal . PlainDateTime {
8
+ export function startOfDay < DateTime extends Temporal . PlainDateTime > (
9
+ dt : DateTime ,
10
+ ) : DateTime {
9
11
return dt . with ( {
10
12
hour : 0 ,
11
13
minute : 0 ,
12
14
second : 0 ,
13
15
millisecond : 0 ,
14
16
microsecond : 0 ,
15
17
nanosecond : 0 ,
16
- } ) ;
18
+ } ) as DateTime ;
17
19
}
You can’t perform that action at this time.
0 commit comments