Skip to content

Instantly share code, notes, and snippets.

@joelalejandro
Created February 16, 2017 07:02
Show Gist options
  • Select an option

  • Save joelalejandro/9ee6c682f1024718064d1f4d24511c5b to your computer and use it in GitHub Desktop.

Select an option

Save joelalejandro/9ee6c682f1024718064d1f4d24511c5b to your computer and use it in GitHub Desktop.
function convertToFullYear(partialYear) {
let year = Number(partialYear);
const fullYear = new Date().getFullYear();
if (year >= 69 && year <= 99) {
year += (Math.floor(fullYear / 100) - 1) * 100;
} else {
year += Math.floor(fullYear / 100) * 100;
}
return year;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment