Closed nafiesl closed 5 years ago
I think we also need to add yob
(year of birth) column on users
table, since we not always get exact person date of birth. I often see a genealogy book/paper, a person with year range like: 1920 - 1995
.
Opinions:
yod
(year of death) & dod
(date of death)?
If someone doesn't know the exact date except the year, I think he/she should be compromise. Not the system.$user->age
is a very good idea. But why are you want to calculate it only by year? IMO, it should be calculated by exact date and show the year only.In the first time I use only date of death, I often found that people don't know exact date of date of their family. They only remember the year. So i fill the date of death with given year
followed by -01-01
, e.g. 2001-01-01
.
But it's not a valid data, right? So i decide to add yod
column as the solution and we have a valid data (year of death instead of invalid given date).
Same idea goes to yob
(year of birth), which hasn't added, yet.
Why we are calculating the year instead of date of birth? Well, I believe we (usually) only need the years old
value.
What do you think @biplobice?
Case 1: In this case, I think your solution is fine.
Case2:
Yeah, we need only the years old
value, but from the actual age.
Suppose, my dob is 2000-07-01
.
On 2019-01-01
, my age is 18 years 6 months 0 days. What we can say 18 year(age)
years old.
On 2019-12-01
, my age is 19 years 5 months 0 days. What we can say 19 year(age)
years old.
But if we, calculate from year to year 2019-2000 = 19
, which is incorrect.
In case, where the dob or dod isn't available, we've to calculate from the year.
OK, I've got your point :ok_hand: Thank you for your suggestion :+1:
@biplobice, I am creating PR #27 for this feature. If you don't mind and have some spare time, kindly please review this feature on person_age
branch.
Thank you in advance.:pray:
@nafiesl Sorry, I’m late due to a busiest weekend. I didn't have opportunity to run, but as your commit seems good to me. Just left one comment.
It will be nice if we have age information of a user/person. For example, if we visit a person profile, we see age of the person after their name.
We can calculate person age by this method:
dob
(date of birth) are filled (must be filled first).dod
(date of death) are filled, we calculate year difference.dod
is null andyod
(year of death) are filled, we calculate year difference.We can use eloquent accessor to set age attribute of a person, like this
$user->age
.