with
input_vars as (
select
to_date(left('{dt.ToString("YYYY-MM-dd")}',10),'YYYY-MM-dd')::timestamp without time zone as m_date,
(case when '{h}' = '8' then 8 else 10 end) as morning_hours
),
parsed_vars as (
select
(m_date + morning_hours * interval '1 hour') as date_start,
(m_date + 1 * interval '1 day' + morning_hours * interval '1 hour') as date_end
from input_vars
)
select
(array['Понедельник','Вторник','Среда','Четверг','Пятница','Суббота','Воскресенье']) [date_part('dow',date_start)]
|| ', ' as dt,
to_char(date_start,'DD.MM.YYYY,') as date,
to_char(date_start, 'dd.mm.YYYY') as date_start,
to_char(date_end, 'dd.mm.YYYY') as date_end
from parsed_vars