Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE
- proper_tz TEXT := COALESCE(
- oils_json_to_text((
- SELECT value
- FROM actor.org_unit_ancestor_setting('lib.timezone',NEW.circ_lib)
- LIMIT 1
- )),
- CURRENT_SETTING('timezone')
- );
- BEGIN
- IF (EXTRACT(EPOCH FROM NEW.duration)::INT % EXTRACT(EPOCH FROM '1 day'::INTERVAL)::INT) = 0 -- day-granular duration
- AND SUBSTRING((NEW.due_date AT TIME ZONE proper_tz)::TIME::TEXT FROM 1 FOR 8) <> '23:59:59' THEN -- has not yet been pushed
- NEW.due_date = ((NEW.due_date AT TIME ZONE proper_tz)::DATE + '1 day'::INTERVAL - '1 second'::INTERVAL) || ' ' || proper_tz;
- END IF;
- RETURN NEW;
- END;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement