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

Solar Calendar #977

Closed
nima87 opened this Issue Jul 23, 2018 · 20 comments

Comments

Projects
None yet
2 participants
@nima87

nima87 commented Jul 23, 2018

Hi,
I need to have Solar(Jalali) calendar dates in Qownnotes. My notes consists in both Persian and English notes. When creating a new note I would like to be able to choose whether the title date to be Persian or Gregorian. Maybe this one is not easy or aesthetically pleasing to the developer or it might be annoying to the users who have no use of the system. So it might be better to ask for an option in the insert menu. One could create a note and manually insert the current time from the insert menu and add the corresponding Markdown characters. Therefore maybe asking for a Jalali date in the insert menu would be more practical.
About the numbers, I wish the numbers for Persian date to be Persian and Gregorian dates to be English.
There is a page on Github containing Jalali Calendar scripts. I thought maybe Qownnotes might be able to use one of these scripts.
https://github.com/jalaali/
And if there could be a feature that the user would give a date either in Jalali or Gregorian to be converted to the other would be very nice and helpful.
Sorry if it was too much.
Thanks in advance.
Nima.

@pbek

This comment has been minimized.

Owner

pbek commented Jul 23, 2018

You can customize headline of new notes completely with the help of a scripting hook:
http://docs.qownnotes.org/en/develop/scripting/README.html#handlenewnoteheadlinehook

As for entering a date into a note you can use a custom action (http://docs.qownnotes.org/en/develop/scripting/README.html#registering-a-custom-action) to implement that.

You might want to add all functions from https://github.com/jalaali/jalaali-js/blob/master/index.js to your script to convert dates (or you could add that js file to your script by including it like in https://github.com/qownnotes/scripts/blob/master/markdown-it/markdown-it.qml).

@pbek

This comment has been minimized.

Owner

pbek commented Jul 23, 2018

If you write a solid script be sure to publish it on https://github.com/qownnotes/scripts (see instructions there) so that it is available in the script repository of QOwnNotes for everyone. ;)

@pbek

This comment has been minimized.

Owner

pbek commented Jul 23, 2018

And feel free to ask if you run into any troubles!

@nima87

This comment has been minimized.

nima87 commented Jul 23, 2018

I'm sorry to disappoint you, I am totally ignorant of writing a script. So if these functions need to be converted to a language which Qownnotes is written in, you might be able to include which part of the Qownnotes documentation I shall read.
And please don't think bad about me or be offended, I might not be able to check or read about this issue in the coming three weeks, I have a very important exam, lots of things needs to be done there and a very short period of time.
Best.

@pbek

This comment has been minimized.

Owner

pbek commented Jul 24, 2018

I am totally ignorant of writing a script

Scripts are written in Javascript, like the library you mentioned. You should be able to use those functions without modifying.

The documentation pages I linked come with code examples you can use to start, like https://github.com/pbek/QOwnNotes/blob/develop/doc/scripting/custom-actions.qml.

@pbek

This comment has been minimized.

Owner

pbek commented Jul 24, 2018

And beside me there are smart people like @Maboroshy who can help you. ;)

@pbek

This comment has been minimized.

Owner

pbek commented Jul 25, 2018

18.07.7

  • added a script Solar (Jalaali) calendar integration to the Script repository
    to attempt to integrate the solar (Jalaali) calendar into QOwnNotes
    • it currently supports creating a headline for new notes with the current
      Jalaali date and time
    • take a look at solar-calendar-integration if you want to improve it
@nima87

This comment has been minimized.

nima87 commented Jul 25, 2018

Hi,
great, it does what it says. I couldn't install it at first and I was desperate, that I pushed the button Load more scripts and it was installed. I told this to let you know my level. Then I compared your Jalaali.js and Jalaali.js on the previously mentioned link and find that you had trimed it, 15 lines from the beginning of Jalaali.js was removed and it was imported in your script with an import command. Now I understood something from your work. I shall check into it after my exams to see how I can use your work as guide to add other things. For example the ability to choose Jalalli or Gregorian, changing the numerals to persian and some other things. But please let me see if I am up to the task or not.
Thank you very much. It was great to see the date in Jalaali calendar, and it was correct, today is 1397/05/03.
Nima.

@pbek

This comment has been minimized.

Owner

pbek commented Jul 25, 2018

For example the ability to choose Jalalli or Gregorian

you can have settings in scripts, see http://docs.qownnotes.org/en/develop/scripting/README.html#registering-script-settings-variables

so for example you could make a checkbox to output Gregorian and bypass the generation of the Jalalli Date if the checkbox was checked by the user in the script settings

@pbek

This comment has been minimized.

Owner

pbek commented Jul 25, 2018

15 lines from the beginning of Jalaali.js was removed

the author was building a NodeJS module, we cannot use that header in plain Javascript

@pbek

This comment has been minimized.

Owner

pbek commented Jul 25, 2018

But if you want to be asked every time you create a new note you might look for http://docs.qownnotes.org/en/develop/scripting/README.html#opening-an-input-dialog-with-a-select-box

@pbek

This comment has been minimized.

Owner

pbek commented Aug 5, 2018

Just tell me if you need more help...

@pbek pbek closed this Aug 5, 2018

@nima87

This comment has been minimized.

nima87 commented Aug 5, 2018

Hi Fabrizio,
I just took my last exam, after my exam I came to check the hints you've provided. I hope that closing the issue was not because of disappointment or getting angry of my not checking into the issue I've created. I'll try to make out the hints to the manual you've previously provided. But it's like learning a new language and I don't know if I can learn fragments of the language to do some very basic things.
Thanks.
Nima.

@pbek

This comment has been minimized.

Owner

pbek commented Aug 5, 2018

I hope that closing the issue was not because of disappointment or getting angry of my not checking into the issue I've created.

No, not at all. It's just that there currently is nothing to be done, except for you... So it doesn't need to stay open. :) Javascript isn't very hard, it's the programming language of the Web. ;)

@nima87

This comment has been minimized.

nima87 commented Aug 5, 2018

Sorry, I mentioned your name wrong, now I was reading your comment on RTL issue and saw it's actually Patrizio. So I need to cope with JS or Qml? I mean searching the web for a manual of Javascript or start with your scripting guide?
For example I want to make the numbers persian and also adding the names of months in Persian. But when it's saved it is saved in the current format you had written. For example the above date:
1397/05/03
3
مرداد
1397
I had to use enter because in LTR mode it didn't show correctly. It is linear and right to left and it reads as: Third of Mordad of 1397 but the saved note name to be: 1397.05.03 or even the Gregorian date. Not that I want to do it now but just having in mind, because it is not going to work if there is problems with RTL mode in the preview mode.
So do these need JS or Qml?

@pbek

This comment has been minimized.

Owner

pbek commented Aug 6, 2018

So I need to cope with JS or Qml?

the qml is just the container for js, if that was the question...

For example I want to make the numbers persian and also adding the names of months in Persian.

are we still talking about the headline? be aware that the file name of your note will be generated from that headline. it's generally not a good idea to use too many special characters that your operating system might not be able to use in file names...

RTL mode in the preview mode

to my knowing there is no automatic RTL detection in HTML, every RTL part would need CSS styling, that's why RTL is a bit tricky in the preview if you want to mix LTR and RTL.

@nima87

This comment has been minimized.

nima87 commented Aug 6, 2018

  1. Yes, the headline, I thought if that script takes the Gregorian date and then convert it to Solar, maybe we can store the Gregorian date for the file name and the Solar date for the headline. Can't we have different variables and use them in different places. One is Gregorian, the other is the Solar in numeral form as the current version and the third is the Solar in alphanumeric form. This would be the extreme case.
  2. For the Persian numbers I should consult to JS. But where should I look for relevant commands? I saw some QAs but couldn't figure out how I should use them. They defined a function which converts the Arabic(English) numbers to Persian(Arabic-Indic) numbers. But how to use that function in Solar.js?
  3. I changed the dashes to slash because Persian date uses slash. Then saving the notes was problematic because at least in windows there are limitations to use certain characters as you know. So I shall have two dates one with slashes in the heading and the other with dots for file names. It's not a problem to use dots in the heading but it's not strictly Persian.
@pbek

This comment has been minimized.

Owner

pbek commented Aug 6, 2018

  1. you could even use a select box to choose from when creating a new note
  2. I guess you will need more libraries
  3. don't ever use slashes in filenames.. but they will be filtered out of the file name by QOwnNotes
@nima87

This comment has been minimized.

nima87 commented Aug 7, 2018

On this page there is js file, is it an example of what you referred to by more libraries?
The 4th item is what I think will be useful for converting Arabic to Hindu Arabic:
4) Convert to Persian numbers from English Number
Used for converting English numbers to Persian.
Example:
persianJs("345").englishNumber(); // returns: ۳۴۵
First I should import this file in Jalali.js, then apply this function to function toJalali is it correct?

@pbek

This comment has been minimized.

Owner

pbek commented Aug 7, 2018

I guess you will need the library from https://github.com/usablica/persian.js/blob/master/persian.js directly.

First I should import this file in Jalali.js, then apply this function to function toJalali is it correct?

correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment