Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Age Calculation of Events #10

Open
1 of 3 tasks
sigrunixia opened this issue May 16, 2023 · 4 comments
Open
1 of 3 tasks

Age Calculation of Events #10

sigrunixia opened this issue May 16, 2023 · 4 comments

Comments

@sigrunixia
Copy link
Member

sigrunixia commented May 16, 2023

For @ProStashio

Is there any code or formula that can be used to calculate someone's age?

Let's say I want to input someone's Birthday for my notes, I would love it to show someone's age. So if I come back to them in an in-game year it would show they are a year older.


CustomJS/Dataview Solution in the interim by @ckennedy666

getBirthday(dv) {
    const fcdate = app.plugins.getPlugin("fantasy-calendar").defaultCalendar.current;
    const pg = dv.current();
    let age = null
    if (pg.Birthday) {
        const bd = pg.Birthday.split("-");
        age = fcdate.year - bd[0] - ((bd[1] > fcdate.month && bd[2] > fcdate.day) ? 1 : 0);
    }
   dv.span(age);
}

  • Yay
  • Nay
  • Implemented
@ckennedy666
Copy link

The challenge I ran into is that with this plugin all the built in Javascript date calculation routines will fail, because of the nonstandard months in use. The above was the best approximation I could come up with. It only works for anniversary calculations, however.

1 similar comment
@ckennedy666

This comment was marked as duplicate.

@valentine195
Copy link
Member

@ckennedy666 I am going to implement a standard API that you will be able to give two dates too and get the timespans back.

@ProStashio
Copy link

Was something ever added? I must admit, I haven't been keeping my eye on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants