Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
Wichtelbot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dnns01
Wichtelbot
Commits
389c7477
Commit
389c7477
authored
3 years ago
by
Benedikt Magnus
Browse files
Options
Downloads
Patches
Plain Diff
DateString utility
parent
2e90581b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/utility/utils.ts
+20
-0
20 additions, 0 deletions
scripts/utility/utils.ts
scripts/wichtelbot/message/modules/generalModule.ts
+8
-5
8 additions, 5 deletions
scripts/wichtelbot/message/modules/generalModule.ts
with
28 additions
and
5 deletions
scripts/utility/utils.ts
+
20
−
0
View file @
389c7477
interface
DateStrings
{
year
:
string
;
month
:
string
;
day
:
string
;
hour
:
string
;
minute
:
string
;
}
export
default
abstract
class
Utils
{
private
static
readonly
defaultMaxWordLength
=
100
;
...
...
@@ -7,6 +16,17 @@ export default abstract class Utils
return
Math
.
floor
(
new
Date
().
getTime
()
/
1000
);
}
public
static
dateToDateStrings
(
unixTime
:
Date
):
DateStrings
{
return
{
'
year
'
:
unixTime
.
getFullYear
().
toString
(),
'
month
'
:
(
unixTime
.
getMonth
()
+
1
).
toString
(),
'
day
'
:
unixTime
.
getDate
().
toString
(),
'
hour
'
:
unixTime
.
getHours
().
toString
(),
'
minute
'
:
unixTime
.
getMinutes
().
toString
().
padStart
(
2
,
'
0
'
),
};
}
/**
* Split text naturally between words if possible and removing unnecessary whitespaces at the break points.
* @param text The text to split.
...
...
This diff is collapsed.
Click to expand it.
scripts/wichtelbot/message/modules/generalModule.ts
+
8
−
5
View file @
389c7477
...
...
@@ -9,6 +9,7 @@ import Member from '../../classes/member';
import
Message
from
'
../../endpoint/definitions/message
'
;
import
State
from
'
../../endpoint/definitions/state
'
;
import
TokenString
from
'
../../../utility/tokenString
'
;
import
Utils
from
'
../../../utility/utils
'
;
import
WichtelEventPhase
from
'
../../../utility/wichtelEvent
'
;
/**
...
...
@@ -69,12 +70,14 @@ export default class GeneralModule
const
registrationPhaseTime
=
new
Date
(
nowInMs
+
randomAdditionInMs
);
const
registrationDateStrings
=
Utils
.
dateToDateStrings
(
registrationPhaseTime
);
const
parameters
=
new
KeyValuePairList
();
parameters
.
addPair
(
'
year
'
,
registration
PhaseTime
.
getFullYear
().
toString
()
);
parameters
.
addPair
(
'
month
'
,
(
registration
PhaseTime
.
getMonth
()
+
1
).
toString
()
);
parameters
.
addPair
(
'
day
'
,
registration
PhaseTime
.
getDate
().
to
String
()
);
parameters
.
addPair
(
'
hour
'
,
registration
PhaseTime
.
getHours
().
toString
()
);
parameters
.
addPair
(
'
minute
'
,
registration
PhaseTime
.
getMinutes
().
toString
().
padStart
(
2
,
'
0
'
)
);
parameters
.
addPair
(
'
year
'
,
registration
DateStrings
.
year
);
parameters
.
addPair
(
'
month
'
,
registration
DateStrings
.
month
);
parameters
.
addPair
(
'
day
'
,
registration
Date
String
s
.
day
);
parameters
.
addPair
(
'
hour
'
,
registration
DateStrings
.
hour
);
parameters
.
addPair
(
'
minute
'
,
registration
DateStrings
.
minute
);
answer
=
Localisation
.
texts
.
contactingTooEarly
.
process
(
message
.
author
,
parameters
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment