And for more fun, an equivalent but more compact template that uses the stored template:
Code:
program:
universe = field('#text');
year = raw_field('#myint');
first_non_empty(
test(universe == 'Star Wars', universe_year(year, 'BBY', 'ABY'), ''),
test(universe == 'Dune', universe_year(year, 'BG', 'AG'), ''),
'Unknown Universe'
)