When is their birthday?

Javascript (ES6), 121 120 119 bytes

(y,s,d)=>[(d=new Date(y,m=s[2]=='s'?1:'r.sune0oapti'.search(s[4]||0),23+d-'343322110012'[m])).getDate(),d.getMonth()+1]

Format for the sign of the zodiac is either:

  • all lower case except the first character
  • all lower case

Test cases

let f =
(y,s,d)=>[(d=new Date(y,m=s[2]=='s'?1:'r.sune0oapti'.search(s[4]||0),23+d-'343322110012'[m])).getDate(),d.getMonth()+1]

console.log(f(1791, 'Capricorn',  5)); // -->  (26, 12)
console.log(f(1815, 'Scorpio',   10)); // -->  ( 2, 11)
console.log(f(1860, 'Pisces',    10)); // -->  (29,  2)
console.log(f(1890, 'Pisces',    20)); // -->  (11,  3)
console.log(f(1900, 'Pisces',    17)); // -->  ( 8,  3)
console.log(f(1938, 'Capricorn', 20)); // -->  (10,  1)
console.log(f(2000, 'Pisces',    17)); // -->  ( 7,  3)


TSQL, 147 bytes

Golfed:

DECLARE @ DATETIME='2000',@s char(3)='Pisces',@d INT=17

SELECT @s=CHARINDEX(@s,'  PisAriTauGemCanLeoVirLibScoSagCap')/3,@=DATEADD(m,@s*1,@)+18+substring('101122334432',@s+1,1)*1+@d SELECT day(@),month(@)

Ungolfed:

DECLARE @ DATETIME='2000',@s char(3)='Pisces',@d INT=17

SELECT 
  @s=CHARINDEX(@s,'  PisAriTauGemCanLeoVirLibScoSagCap')/3,
  @=DATEADD(m,@s*1,@)+18+substring('101122334432',@s+1,1)*1+@d
SELECT day(@),month(@)

Fiddle

Tags:

Date

Code Golf