Skip to content

Commit e2ec762

Browse files
committed
feat(skill/date_time): get current date and time
1 parent e70d0a0 commit e2ec762

File tree

12 files changed

+65
-165
lines changed

12 files changed

+65
-165
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "../../../../schemas/skill-schemas/skill-config.json",
3+
"actions": {
4+
"current_date_time": {
5+
"type": "logic",
6+
"utterance_samples": [
7+
"What time is it?",
8+
"What's today date?",
9+
"Do you have the time?",
10+
"Can you tell me the current time?",
11+
"What is the date today?",
12+
"What day is it?",
13+
"What day of the week are we?",
14+
"What day of the week is it?"
15+
]
16+
}
17+
},
18+
"answers": {
19+
"current_date_time": [
20+
"It's %weekday%, %month% %day%, %year%, and it's %hours%:%minutes%:%seconds%."
21+
]
22+
}
23+
}
File renamed without changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "../../../schemas/skill-schemas/skill.json",
3+
"name": "Date/Time",
4+
"bridge": "nodejs",
5+
"version": "1.0.0",
6+
"description": "Provide date and time related information.",
7+
"author": {
8+
"name": "Théo LUDWIG",
9+
"email": "contact@theoludwig.fr",
10+
"url": "https://theoludwig.fr"
11+
}
12+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { ActionFunction } from '@sdk/types'
2+
import { leon } from '@sdk/leon'
3+
4+
import { zeroPad } from '../lib/zeroPad'
5+
6+
export const run: ActionFunction = async function (params) {
7+
const currentDate = new Date()
8+
await leon.answer({
9+
key: 'current_date_time',
10+
data: {
11+
weekday: currentDate.toLocaleString(params.lang, { weekday: 'long' }),
12+
month: currentDate.toLocaleString(params.lang, { month: 'long' }),
13+
day: currentDate.getDate(),
14+
year: currentDate.getFullYear(),
15+
hours: zeroPad(currentDate.getHours()),
16+
minutes: zeroPad(currentDate.getMinutes()),
17+
seconds: zeroPad(currentDate.getSeconds())
18+
}
19+
})
20+
}
File renamed without changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/**
2+
* Pads a number with zeros.
3+
*
4+
* @example zeroPad(1, 2) // '01'
5+
* @example zeroPad(10, 2) // '10'
6+
*/
7+
export const zeroPad = (number: number, places = 2): string => {
8+
return number.toString().padStart(places, '0')
9+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

skills/utilities/timekeeper/config/en.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

skills/utilities/timekeeper/skill.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)