fix repeatable migrations
This commit is contained in:
20
db/routines/R__040_fn_planning_slot_boundary_prague.sql
Normal file
20
db/routines/R__040_fn_planning_slot_boundary_prague.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- začátek aktuálního (+offset) 15min slotu v Europe/Prague jako timestamptz (UTC instants)
|
||||
|
||||
create or replace function ems.fn_planning_slot_boundary_prague(p_offset_slots int default 0)
|
||||
returns timestamptz
|
||||
language sql
|
||||
stable
|
||||
as $fn$
|
||||
select (
|
||||
(date_trunc('day', loc.ts)
|
||||
+ make_interval(
|
||||
hours => extract(hour from loc.ts)::int,
|
||||
mins => (floor(extract(minute from loc.ts) / 15) * 15)::int
|
||||
)
|
||||
)::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;
|
||||
$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.';
|
||||
Reference in New Issue
Block a user