Other Calendar and date system in Tiddlywiki

131 views
Skip to first unread message

Mohammad

unread,
Apr 11, 2020, 9:41:37 AM4/11/20
to TiddlyWiki
You may know there are different types of calendar! See https://en.wikipedia.org/wiki/List_of_calendars

Tiddlywiki at the moment only shows time/date in tiddler subtitle as Georgian Calendar.
Is there any settings / features in Tiddlywiki to show/use other Calendar system like Jalali, Hijri, ...

I am not sure if localization like Tiddlywiki language pack change this or not?



I appreciate if you share your thoughts/plugins/codes...


--Mohammad

PMario

unread,
Apr 11, 2020, 10:01:20 AM4/11/20
to TiddlyWiki
On Saturday, April 11, 2020 at 3:41:37 PM UTC+2, Mohammad wrote:
You may know there are different types of calendar! See https://en.wikipedia.org/wiki/List_of_calendars

Tiddlywiki at the moment only shows time/date in tiddler subtitle as Georgian Calendar.
Is there any settings / features in Tiddlywiki to show/use other Calendar system like Jalali, Hijri, ...

There is no other calendar built into TW or even the browser. ... So  we would need a 3rd party library.
 
I am not sure if localization like Tiddlywiki language pack change this or not?

no

-m

Mohammad

unread,
Apr 11, 2020, 10:19:12 AM4/11/20
to TiddlyWiki
Hi Mario,

Thanks for clarification!

-- Mohammad

PMario

unread,
Apr 13, 2020, 9:56:35 AM4/13/20
to TiddlyWiki
Hi Mohammad,


So there may be a possibility to convert dates from one system to an other, built in to the browser.
But it needs more investigating.

-mario

PMario

unread,
Apr 13, 2020, 10:02:31 AM4/13/20
to TiddlyWiki


On Monday, April 13, 2020 at 3:56:35 PM UTC+2, PMario wrote:

Those functions are not only for dates, but also for numbers and currencies


-mario

Mohammad

unread,
Apr 13, 2020, 10:05:11 AM4/13/20
to TiddlyWiki
Many thanks Mario! 

It is promising! and seems all modern browsers support it!


Best
Mohammad
Hope I can help, if not JS coding :-) 

-mario

Mohammad

unread,
Apr 13, 2020, 10:07:27 AM4/13/20
to TiddlyWiki
That is true. I checked Int here

and as I said above most modern browsers support it. I think TW language pack can have an option to use localization through Intl API.

-mario

Mark S.

unread,
Apr 13, 2020, 10:50:44 AM4/13/20
to TiddlyWiki
To me it looks like it does format conversion (how dates are presented), but maybe not actual data (date) conversion.

PMario

unread,
Apr 13, 2020, 12:53:10 PM4/13/20
to TiddlyWiki
On Monday, April 13, 2020 at 4:50:44 PM UTC+2, Mark S. wrote:
To me it looks like it does format conversion (how dates are presented), but maybe not actual data (date) conversion.

Have a look at: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl right above heading "Locale negotiation" there is a paragraph like:

  • "en-GB-u-ca-islamic": use British English with the Islamic (Hijri) calendar, where the Gregorian date 14 October, 2017 is the Hijri date 24 Muharram, 1439.

Which looks promising.

-m

PMario

unread,
Apr 13, 2020, 12:54:36 PM4/13/20
to TiddlyWiki
.. but this seems to be the wrong one :/

PMario

unread,
Apr 13, 2020, 1:26:32 PM4/13/20
to TiddlyWiki
Hi

found this: https://github.com/farhadi/JalaliJSCalendar/blob/master/jalali.js which contains some transformation calculations BUT it modifies the Date() prototype, which is a real "no no". But the calculations should be usable.

-m

Mark S.

unread,
Apr 13, 2020, 2:15:42 PM4/13/20
to TiddlyWiki

To get the human-readable version of their sample, I needed more code:

function myFunction() {
const dtf = new Intl.DateTimeFormat('en-GB-u-ca-islamic', { year: 'numeric', month: 'long', day: '2-digit' })

 
var d = new Date("14 October, 2017");

const [{ value: mo },,{ value: da },,{ value: ye }] = dtf.formatToParts(d)

 
var n = dtf.formatToParts(d)
  document
.getElementById("demo").innerHTML = da+" "+mo+" "+ye;
}

Which yielded

24 Muharram 1439

So, I guess it really is in there (assuming the output was right). The other article I read made it seem impossibly complex.
Reply all
Reply to author
Forward
0 new messages