Skip to content

Commit b845357

Browse files
committed
Date of birth cannot be in t
1 parent 8980325 commit b845357

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

LongevityWorldCup.Website/wwwroot/js/pheno-age.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ window.PhenoAge.calculateAgeFromDOB = function (birthDate) {
2929

3030
const today = new Date();
3131

32-
if (birthDate > today) throw new Error("DOB is in the future.");
32+
if (birthDate > today) throw new Error("Date of birth cannot be in the future.");
3333

3434
// Calculate total days lived
3535
const msPerDay = 1000 * 60 * 60 * 24;

LongevityWorldCup.Website/wwwroot/onboarding/pheno-age.html

+9-5
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="250">
397397
</main>
398398
<!--FOOTER-->
399399
<!-- JavaScript -->
400-
<script src="/js/pheno-age.js?v=1.1"></script> <!-- Link to your external script -->
400+
<script src="/js/pheno-age.js?v=1.2"></script> <!-- Link to your external script -->
401401
<script>
402402
updateMainProgress(2);
403403

@@ -483,10 +483,14 @@ <h2 data-aos="fade" data-aos-duration="700" data-aos-delay="250">
483483
}
484484

485485
const dobValue = new Date(year, month, day); // Month is 0-based (0 = Jan), Day is 1-based (1 = 1st day, 0 = last day of previous month)
486-
const chronologicalAge = window.PhenoAge.calculateAgeFromDOB(dobValue);
487-
488-
if (chronologicalAge < 0) {
489-
customAlert("Date of birth cannot be in the future.");
486+
let chronologicalAge;
487+
try {
488+
chronologicalAge = window.PhenoAge.calculateAgeFromDOB(dobValue);
489+
if (chronologicalAge < 0) {
490+
throw new Error("Invalid Date of Birth: You cannot be born in the future.");
491+
}
492+
} catch (error) {
493+
customAlert(error.message);
490494
return;
491495
}
492496

LongevityWorldCup.Website/wwwroot/partials/leaderboard-content.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,7 @@ <h3>Proofs</h3>
10901090
</div>
10911091

10921092
<script src="/js/divisionIcons.js?v=1.0"></script>
1093-
<script src="/js/pheno-age.js?v=1.1"></script>
1093+
<script src="/js/pheno-age.js?v=1.2"></script>
10941094
<script>
10951095
let athleteResults = [];
10961096

0 commit comments

Comments
 (0)