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

Kanji shown wrong in the year #18

Open
1 task
carolinesweetpea opened this issue Nov 23, 2024 · 4 comments
Open
1 task

Kanji shown wrong in the year #18

carolinesweetpea opened this issue Nov 23, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@carolinesweetpea
Copy link
Contributor

Checklist:

  • [x ] I updated to the latest version available
  • I cleared the cache of my browser

Release with the issue:
Latest
Last working release (if known):
Unknown
Browser and Operating System:
Not browser/OS dependent

Description of problem:

The Kanji is wrong :(

2024 is shown as 二千百十四年 (which is actually 2114)

wherea it should be shown as 二千二十四年

I tried to fix it, however I also can't get it running in a dev environment - yarn start doesn't work, and my TS/JS skills aren't good enough at the moment to know how to get things running :( Will keep looking at the issue, and submit a PR if I get htat far.

I think the issue is in line 63 of card.ts - there should be an additional && prefix < 10 clause, which is what is putting in the extra 百 but I'm not sure at this stage what is not adding the 二 when it should be in there

Javascript errors shown in the web inspector (if applicable):


Additional information:

@carolinesweetpea carolinesweetpea added the bug Something isn't working label Nov 23, 2024
@carolinesweetpea
Copy link
Contributor Author

This is my test script to fix the output, which I think works (runing with ts-node test.ts)

I'll put this into a PR, but it will be untested with HA

const KANJI_WEEKDAYS = "日月火水木金土";
const TENS = ["", "十", "百", "千"];


const number = 2024

    let output = "";
    const nlength = number.toString().length;
    for (let i = nlength - 1; i >= 0; i--) {
      const divisor = Math.pow(10, i);
      const num = number % divisor;
      const prefix = Math.floor(number / divisor);
      const digit = prefix % 10
      if (digit > 1 && digit < 10) {
	output += KANJI_NUMBERS[digit];
      }
      if (digit > 0) {
        output += TENS[i];
      }
    }
console.log("Output:",output)

@sopelj
Copy link
Owner

sopelj commented Nov 24, 2024

Good catch! Thanks for that. I'll try testing the PR and merge it this week as soon as I have a moment.

@sopelj
Copy link
Owner

sopelj commented Nov 29, 2024

Seems to work well, thanks! I created a beta release if you want to try it.

@carolinesweetpea
Copy link
Contributor Author

Would definitely like to try the beta release - thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants