Skip to content

Instantly share code, notes, and snippets.

@ybouhjira
Created January 21, 2014 19:53
Show Gist options
  • Save ybouhjira/8547118 to your computer and use it in GitHub Desktop.
Save ybouhjira/8547118 to your computer and use it in GitHub Desktop.
month lengh function
int month_length(int year, int month)
{
return (month == 2) ? 28 + !(year % 4) : 30 + (((month * 9) >> 3) & 1);
}
@ybouhjira
Copy link
Author

int longueur_mois(int an, int mois)
{
  assert(1 <= mois && mois <= 12);
  return mois == 2 ? an % 4? 28 : 29 : 30 + (((mois * 9) / 8) & 1);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment