Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22398060
date.ts
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
date.ts
View Options
import
{
Context
}
from
"koa"
;
import
{
SimpleInput
,
SimpleInputOptions
}
from
"../controls/simple-input.js"
;
import
{
FormDataValue
}
from
"../form-types.js"
;
import
{
FieldParseResult
}
from
"./field.js"
;
import
{
SimpleFormField
}
from
"./simple-form-field.js"
;
export
class
DateField
<
Required
extends
boolean
>
extends
SimpleFormField
<
Required
,
SimpleInput
,
Date
>
{
constructor
(
required
:
Required
)
{
super
(
required
,
"date"
);
}
public
getEmptyValue
()
:
Date
{
return
new
Date
(
"1970-01-01 00:00"
);
}
async
parse
(
ctx
:
Context
,
raw_value
:
FormDataValue
)
:
Promise
<
FieldParseResult
<
Date
>>
{
return
{
error
:
null
,
parsable
:
true
,
parsed_value
:
new
Date
(
raw_value
as
string
),
};
}
getControl
()
:
SimpleInput
<
SimpleInputOptions
>
{
return
new
SimpleInput
(
this
,
{
label
:
this
.
label
||
this
.
name
,
type
:
this
.
type
,
});
}
async
parsedToSealious
(
parsed
:
Date
)
:
Promise
<
string
|
null
>
{
return
`
${
parsed
.
getFullYear
()
}
-
${
(
parsed
.
getMonth
()
+
1
)
.
toString
()
.
padStart
(
2
,
"0"
)
}
-
${
parsed
.
getDate
().
toString
().
padStart
(
2
,
"0"
)
}
`
;
}
}
File Metadata
Details
Attached
Mime Type
application/javascript
Expires
Fri, Nov 27, 17:19 (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1199246
Default Alt Text
date.ts (1 KB)
Attached To
Mode
rSGEN sealgen
Attached
Detach File
Event Timeline