@@ -18,7 +18,7 @@ export class _Date {
18
18
* @param years
19
19
* @param refDate
20
20
*/
21
- past ( years ?: number , refDate ?: string ) {
21
+ past ( years ?: number , refDate ?: string ) : Date {
22
22
let date = new Date ( ) ;
23
23
if ( typeof refDate !== 'undefined' ) {
24
24
date = new Date ( Date . parse ( refDate ) ) ;
@@ -43,7 +43,7 @@ export class _Date {
43
43
* @param years
44
44
* @param refDate
45
45
*/
46
- future ( years ?: number , refDate ?: string ) {
46
+ future ( years ?: number , refDate ?: string ) : Date {
47
47
let date = new Date ( ) ;
48
48
if ( typeof refDate !== 'undefined' ) {
49
49
date = new Date ( Date . parse ( refDate ) ) ;
@@ -68,7 +68,7 @@ export class _Date {
68
68
* @param from
69
69
* @param to
70
70
*/
71
- between ( from : string , to : string ) {
71
+ between ( from : string , to : string ) : Date {
72
72
const fromMilli = Date . parse ( from ) ;
73
73
const dateOffset = this . faker . datatype . number ( Date . parse ( to ) - fromMilli ) ;
74
74
@@ -83,16 +83,18 @@ export class _Date {
83
83
* @method faker.date.between
84
84
* @param from
85
85
* @param to
86
+ * @param num
86
87
*/
87
- betweens ( from , to , num ) {
88
+ betweens ( from : string , to : string , num ?: number ) : Date [ ] {
88
89
if ( typeof num == 'undefined' ) {
89
90
num = 3 ;
90
91
}
91
- const newDates = [ ] ;
92
+ const newDates : Date [ ] = [ ] ;
92
93
let fromMilli = Date . parse ( from ) ;
93
94
const dateOffset = ( Date . parse ( to ) - fromMilli ) / ( num + 1 ) ;
94
- let lastDate = from ;
95
+ let lastDate : string | Date = from ;
95
96
for ( let i = 0 ; i < num ; i ++ ) {
97
+ // TODO @Shinigami 92 2022-01-11: It may be a bug that `lastDate` is passed to parse if it's a `Date` not a `string`
96
98
fromMilli = Date . parse ( lastDate ) ;
97
99
lastDate = new Date ( fromMilli + dateOffset ) ;
98
100
newDates . push ( lastDate ) ;
@@ -107,7 +109,7 @@ export class _Date {
107
109
* @param days
108
110
* @param refDate
109
111
*/
110
- recent ( days , refDate ) {
112
+ recent ( days ?: number , refDate ?: string ) : Date {
111
113
let date = new Date ( ) ;
112
114
if ( typeof refDate !== 'undefined' ) {
113
115
date = new Date ( Date . parse ( refDate ) ) ;
@@ -132,7 +134,7 @@ export class _Date {
132
134
* @param days
133
135
* @param refDate
134
136
*/
135
- soon ( days , refDate ) {
137
+ soon ( days ?: number , refDate ?: string ) : Date {
136
138
let date = new Date ( ) ;
137
139
if ( typeof refDate !== 'undefined' ) {
138
140
date = new Date ( Date . parse ( refDate ) ) ;
@@ -156,7 +158,7 @@ export class _Date {
156
158
* @method faker.date.month
157
159
* @param options
158
160
*/
159
- month ( options ) {
161
+ month ( options ?: { abbr ?: boolean ; context ?: boolean } ) {
160
162
options = options || { } ;
161
163
162
164
let type = 'wide' ;
@@ -182,7 +184,7 @@ export class _Date {
182
184
* @method faker.date.weekday
183
185
* @param options
184
186
*/
185
- weekday ( options ) {
187
+ weekday ( options ?: { abbr ?: boolean ; context ?: boolean } ) {
186
188
options = options || { } ;
187
189
188
190
let type = 'wide' ;
0 commit comments