2024-09-11 17:24:20 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
2024-09-12 00:03:29 +02:00
|
|
|
namespace _zeitbild.helpers
|
2024-09-11 17:24:20 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @todo timezone
|
|
|
|
|
*/
|
|
|
|
|
function ical_datetime_to_own_datetime(
|
|
|
|
|
ical_datetime : lib_plankton.ical.type_datetime
|
2024-09-26 16:47:38 +02:00
|
|
|
) : lib_plankton.pit.type_datetime
|
2024-09-11 17:24:20 +02:00
|
|
|
{
|
|
|
|
|
return {
|
|
|
|
|
"timezone_shift": 0,
|
|
|
|
|
"date": {
|
|
|
|
|
"year": ical_datetime.date.year,
|
|
|
|
|
"month": ical_datetime.date.month,
|
|
|
|
|
"day": ical_datetime.date.day,
|
|
|
|
|
},
|
|
|
|
|
"time": (
|
|
|
|
|
(ical_datetime.time === null)
|
|
|
|
|
?
|
|
|
|
|
null
|
|
|
|
|
:
|
|
|
|
|
{
|
|
|
|
|
"hour": ical_datetime.time.hour,
|
|
|
|
|
"minute": ical_datetime.time.minute,
|
|
|
|
|
"second": ical_datetime.time.second,
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @todo timezone
|
|
|
|
|
*/
|
|
|
|
|
export function ical_dt_to_own_datetime(
|
|
|
|
|
ical_dt: lib_plankton.ical.type_dt
|
2024-09-26 16:47:38 +02:00
|
|
|
) : lib_plankton.pit.type_datetime
|
2024-09-11 17:24:20 +02:00
|
|
|
{
|
|
|
|
|
return {
|
|
|
|
|
"timezone_shift": 0,
|
|
|
|
|
"date": ical_dt.value.date,
|
|
|
|
|
"time": (
|
|
|
|
|
(ical_dt.value.time === null)
|
|
|
|
|
?
|
|
|
|
|
null
|
|
|
|
|
:
|
|
|
|
|
{
|
|
|
|
|
"hour": ical_dt.value.time.hour,
|
|
|
|
|
"minute": ical_dt.value.time.minute,
|
|
|
|
|
"second": ical_dt.value.time.second,
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-12 16:35:57 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*/
|
|
|
|
|
export async function template_coin(
|
|
|
|
|
name : string,
|
|
|
|
|
data : Record<string, string>
|
|
|
|
|
) : Promise<string>
|
|
|
|
|
{
|
2025-09-25 16:41:17 +02:00
|
|
|
const content : string = await lib_plankton.cache.get<string>(
|
|
|
|
|
_zeitbild.cache_templates,
|
|
|
|
|
name,
|
|
|
|
|
null,
|
|
|
|
|
() => (
|
|
|
|
|
lib_plankton.file.read(
|
|
|
|
|
lib_plankton.string.coin(
|
|
|
|
|
"templates/{{name}}.html.tpl",
|
|
|
|
|
{
|
|
|
|
|
"name": name,
|
|
|
|
|
}
|
2024-09-12 16:35:57 +02:00
|
|
|
)
|
|
|
|
|
)
|
2025-09-25 16:41:17 +02:00
|
|
|
.then(
|
|
|
|
|
x => Promise.resolve<string>(x.toString())
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
2024-09-12 16:35:57 +02:00
|
|
|
return Promise.resolve<string>(
|
|
|
|
|
lib_plankton.string.coin(
|
|
|
|
|
content,
|
|
|
|
|
data
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @todo outsource
|
|
|
|
|
*/
|
|
|
|
|
export async function promise_row<type_result>(
|
|
|
|
|
members : Array<
|
|
|
|
|
() => Promise<type_result>
|
|
|
|
|
>
|
|
|
|
|
) : Promise<
|
|
|
|
|
Array<
|
|
|
|
|
type_result
|
|
|
|
|
>
|
|
|
|
|
>
|
|
|
|
|
{
|
|
|
|
|
let results : Array<type_result> = [];
|
|
|
|
|
for await (const member of members) {
|
|
|
|
|
results.push(await member());
|
|
|
|
|
}
|
|
|
|
|
return Promise.resolve<Array<type_result>>(results);
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-11 17:24:20 +02:00
|
|
|
}
|