Commit d1b96565 authored by stph's avatar stph
Browse files

Implement semester PL/pgSQL function

parent c40a7baa
......@@ -76,9 +76,22 @@ BEGIN
END;
$$ LANGUAGE PLPGSQL;
/** TODO **/
CREATE OR REPLACE FUNCTION semester(DATE) RETURNS CHAR(1) AS $$
/* Returns semestre from Api, using begin date */
DECLARE
d ALIAS FOR $1;
m INTEGER;
BEGIN
RETURN 'H';
m = DATE_PART('month', $1);
/* Winter intersemester is either january or february or march */
IF m = 1 OR m = 2 OR m = 3 THEN
RETURN 'H';
/* Summer intersemester is either june or july or august or september */
ELSIF m = 6 OR m = 7 OR m = 3 OR m = 9 THEN
RETURN 'E';
ELSE
RETURN 'X';
END IF;
END;
$$ LANGUAGE PLPGSQL;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment