implmentace plan guardu
This commit is contained in:
@@ -1,6 +1,12 @@
|
||||
-- začátek aktuálního (+offset) 15min slotu v Europe/Prague jako timestamptz (UTC instants)
|
||||
-- Začátek aktuálního (+offset) 15min slotu v Europe/Prague jako timestamptz (UTC instants).
|
||||
-- Volitelné p_at (např. job po uzavření slotu); null = now().
|
||||
|
||||
create or replace function ems.fn_planning_slot_boundary_prague(p_offset_slots int default 0)
|
||||
drop function if exists ems.fn_planning_slot_boundary_prague(int);
|
||||
|
||||
create or replace function ems.fn_planning_slot_boundary_prague(
|
||||
p_offset_slots int default 0,
|
||||
p_at timestamptz default null
|
||||
)
|
||||
returns timestamptz
|
||||
language sql
|
||||
stable
|
||||
@@ -13,8 +19,10 @@ as $fn$
|
||||
)
|
||||
)::timestamp at time zone 'Europe/Prague'
|
||||
) + make_interval(mins => coalesce(p_offset_slots, 0) * 15)
|
||||
from (select now() at time zone 'Europe/Prague' as ts) loc;
|
||||
from (
|
||||
select coalesce(p_at, now()) at time zone 'Europe/Prague' as ts
|
||||
) loc;
|
||||
$fn$;
|
||||
|
||||
comment on function ems.fn_planning_slot_boundary_prague(int) is
|
||||
'Začátek 15min slotu v časové zóně site provozu (Europe/Prague floor); offset v násobcích 15 min.';
|
||||
comment on function ems.fn_planning_slot_boundary_prague(int, timestamptz) is
|
||||
'Začátek 15min slotu (Europe/Prague floor); offset v násobcích 15 min; p_at volitelně místo now().';
|
||||
|
||||
Reference in New Issue
Block a user