NodeJS -> B4X [job already given!]

ilan

Expert
Licensed User
Longtime User
hi

i would like to convert this NodeJS library to B4x:


this is the app.js i run using NodeJS and i am getting what i want:

B4X:
const KosherZmanim = require("kosher-zmanim");

var date = new Date();

    const options = {
        date: date.toISOString().substr(0, 19),
        timeZoneId: "Asia/Jerusalem",
        locationName: "Haifa",
        latitude: Number.parseFloat("32.817280"),
        longitude: Number.parseFloat("34.988762"),
        elevation: Number.parseFloat("0"),
        complexZmanim: true,
    };
                  
    const json = KosherZmanim.getZmanimJson(options);
    
    console.log(JSON.stringify(json, null, 2));

returned Json String:

{
"metadata": {
"date": "2024-04-24",
"type": "com.kosherjava.zmanim.ComplexZmanimCalendar",
"algorithm": "US National Oceanic and Atmospheric Administration Algorithm",
"location": "Haifa",
"latitude": "32.81728",
"longitude": "34.988762",
"elevation": "0.0",
"timeZoneName": "Israel Daylight Time",
"timeZoneID": "Asia/Jerusalem",
"timeZoneOffset": "3.0"
},
"Zmanim": {
"Alos26Degrees": "2024-04-24T03:45:37+03:00",
"Alos120Zmanis": "2024-04-24T03:46:56+03:00",
"Alos120": "2024-04-24T03:59:47+03:00",
"Alos96Zmanis": "2024-04-24T04:13:30+03:00",
"Alos90Zmanis": "2024-04-24T04:20:09+03:00",
"Alos19Point8Degrees": "2024-04-24T04:21:20+03:00",
"Alos96": "2024-04-24T04:23:47+03:00",
"Alos19Degrees": "2024-04-24T04:25:45+03:00",
"Alos90": "2024-04-24T04:29:47+03:00",
"Alos18Degrees": "2024-04-24T04:31:14+03:00",
"BeginAstronomicalTwilight": "2024-04-24T04:31:14+03:00",
"AlosBaalHatanya": "2024-04-24T04:37:13+03:00",
"Alos72Zmanis": "2024-04-24T04:40:05+03:00",
"Alos16Point1Degrees": "2024-04-24T04:41:31+03:00",
"AlosHashachar": "2024-04-24T04:41:31+03:00",
"Alos72": "2024-04-24T04:47:47+03:00",
"Alos60": "2024-04-24T04:59:47+03:00",
"BeginNauticalTwilight": "2024-04-24T05:03:12+03:00",
"Misheyakir11Point5Degrees": "2024-04-24T05:05:48+03:00",
"Misheyakir11Degrees": "2024-04-24T05:08:24+03:00",
"Misheyakir10Point2Degrees": "2024-04-24T05:12:32+03:00",
"Misheyakir9Point5Degrees": "2024-04-24T05:16:08+03:00",
"Misheyakir7Point65Degrees": "2024-04-24T05:25:36+03:00",
"BeginCivilTwilight": "2024-04-24T05:33:58+03:00",
"SeaLevelSunrise": "2024-04-24T05:59:47+03:00",
"Sunrise": "2024-04-24T05:59:47+03:00",
"SofZmanShmaMGA120Minutes": "2024-04-24T08:19:04+03:00",
"SofZmanShmaAlos16Point1ToSunset": "2024-04-24T08:20:22+03:00",
"SofZmanShmaMGA96MinutesZmanis": "2024-04-24T08:25:56+03:00",
"SofZmanShmaAlos16Point1ToTzaisGeonim7Point083Degrees": "2024-04-24T08:28:13+03:00",
"SofZmanShmaMGA90MinutesZmanis": "2024-04-24T08:29:15+03:00",
"SofZmanShmaAteretTorah": "2024-04-24T08:29:17+03:00",
"SofZmanShmaMGA19Point8Degrees": "2024-04-24T08:29:56+03:00",
"SofZmanShmaMGA96Minutes": "2024-04-24T08:31:04+03:00",
"SofZmanShmaMGA90Minutes": "2024-04-24T08:34:04+03:00",
"SofZmanShmaMGA18Degrees": "2024-04-24T08:34:52+03:00",
"SofZmanShmaMGA72MinutesZmanis": "2024-04-24T08:39:13+03:00",
"SofZmanShmaMGA16Point1Degrees": "2024-04-24T08:40:00+03:00",
"SofZmanShmaMGA": "2024-04-24T08:43:04+03:00",
"SofZmanShmaMGA72Minutes": "2024-04-24T08:43:04+03:00",
"SofZmanShmaBaalHatanya": "2024-04-24T09:17:13+03:00",
"SofZmanShmaGRA": "2024-04-24T09:19:04+03:00",
"SofZmanShmaKolEliyahu": "2024-04-24T09:19:55+03:00",
"SofZmanShma3HoursBeforeChatzos": "2024-04-24T09:38:21+03:00",
"SofZmanShmaFixedLocal": "2024-04-24T09:40:02+03:00",
"SofZmanTfilaMGA120Minutes": "2024-04-24T09:45:30+03:00",
"SofZmanTfilahAteretTorah": "2024-04-24T09:45:42+03:00",
"SofZmanTfilaMGA96MinutesZmanis": "2024-04-24T09:50:04+03:00",
"SofZmanTfilaMGA90MinutesZmanis": "2024-04-24T09:52:17+03:00",
"SofZmanTfilaMGA19Point8Degrees": "2024-04-24T09:52:48+03:00",
"SofZmanTfilaMGA96Minutes": "2024-04-24T09:53:30+03:00",
"SofZmanTfilaMGA90Minutes": "2024-04-24T09:55:30+03:00",
"SofZmanTfilaMGA18Degrees": "2024-04-24T09:56:05+03:00",
"SofZmanTfilaMGA72MinutesZmanis": "2024-04-24T09:58:56+03:00",
"SofZmanAchilasChametzMGA16Point1Degrees": "2024-04-24T09:59:30+03:00",
"SofZmanTfilaMGA16Point1Degrees": "2024-04-24T09:59:30+03:00",
"SofZmanAchilasChametzMGA72Minutes": "2024-04-24T10:01:30+03:00",
"SofZmanTfilaMGA": "2024-04-24T10:01:30+03:00",
"SofZmanTfilaMGA72Minutes": "2024-04-24T10:01:30+03:00",
"SofZmanAchilasChametzBaalHatanya": "2024-04-24T10:24:16+03:00",
"SofZmanTfilaBaalHatanya": "2024-04-24T10:24:16+03:00",
"SofZmanAchilasChametzGRA": "2024-04-24T10:25:30+03:00",
"SofZmanTfilaGRA": "2024-04-24T10:25:30+03:00",
"SofZmanTfila2HoursBeforeChatzos": "2024-04-24T10:38:21+03:00",
"SofZmanTfilaFixedLocal": "2024-04-24T10:40:02+03:00",
"SofZmanBiurChametzMGA16Point1Degrees": "2024-04-24T11:18:59+03:00",
"SofZmanBiurChametzMGA72Minutes": "2024-04-24T11:19:56+03:00",
"SofZmanBiurChametzBaalHatanya": "2024-04-24T11:31:19+03:00",
"SofZmanBiurChametzGRA": "2024-04-24T11:31:56+03:00",
"Chatzos": "2024-04-24T12:38:21+03:00",
"SunTransit": "2024-04-24T12:38:21+03:00",
"FixedLocalChatzos": "2024-04-24T12:40:02+03:00",
"MinchaGedolaAteretTorah": "2024-04-24T12:56:42+03:00",
"MinchaGedola30Minutes": "2024-04-24T13:08:21+03:00",
"MinchaGedola": "2024-04-24T13:11:34+03:00",
"MinchaGedolaGreaterThan30": "2024-04-24T13:11:34+03:00",
"MinchaGedolaBaalHatanya": "2024-04-24T13:11:53+03:00",
"MinchaGedolaBaalHatanyaGreaterThan30": "2024-04-24T13:11:53+03:00",
"MinchaGedola72Minutes": "2024-04-24T13:17:34+03:00",
"MinchaGedola16Point1Degrees": "2024-04-24T13:18:14+03:00",
"MinchaKetana": "2024-04-24T16:30:51+03:00",
"MinchaKetanaBaalHatanya": "2024-04-24T16:33:02+03:00",
"MinchaKetanaAteretTorah": "2024-04-24T16:45:55+03:00",
"MinchaKetana72Minutes": "2024-04-24T17:12:51+03:00",
"MinchaKetana16Point1Degrees": "2024-04-24T17:16:43+03:00",
"PlagAlosToSunset": "2024-04-24T17:45:44+03:00",
"PlagHamincha": "2024-04-24T17:53:53+03:00",
"PlagHaminchaBaalHatanya": "2024-04-24T17:56:50+03:00",
"PlagAlos16Point1ToTzaisGeonim7Point083Degrees": "2024-04-24T18:13:51+03:00",
"PlagHaminchaAteretTorah": "2024-04-24T18:21:25+03:00",
"PlagHamincha60Minutes": "2024-04-24T18:41:23+03:00",
"PlagHamincha72Minutes": "2024-04-24T18:50:53+03:00",
"PlagHamincha16Point1Degrees": "2024-04-24T18:56:05+03:00",
"PlagHamincha72MinutesZmanis": "2024-04-24T18:57:00+03:00",
"BainHasmashosYereim2Point99Degrees": "2024-04-24T18:57:47+03:00",
"BainHasmashosYereim18Minutes": "2024-04-24T18:58:55+03:00",
"CandleLighting": "2024-04-24T18:58:55+03:00",
"BainHasmashosYereim2Point8Degrees": "2024-04-24T18:59:00+03:00",
"BainHasmashosYereim16Point875Minutes": "2024-04-24T19:00:03+03:00",
"BainHasmashosYereim2Point1Degrees": "2024-04-24T19:02:26+03:00",
"BainHasmashosYereim13Point5Minutes": "2024-04-24T19:03:25+03:00",
"PlagHamincha18Degrees": "2024-04-24T19:04:16+03:00",
"PlagHamincha90Minutes": "2024-04-24T19:05:08+03:00",
"PlagHamincha96Minutes": "2024-04-24T19:09:53+03:00",
"PlagHamincha19Point8Degrees": "2024-04-24T19:12:09+03:00",
"PlagHamincha90MinutesZmanis": "2024-04-24T19:12:46+03:00",
"SeaLevelSunset": "2024-04-24T19:16:55+03:00",
"Sunset": "2024-04-24T19:16:55+03:00",
"PlagHamincha96MinutesZmanis": "2024-04-24T19:18:02+03:00",
"PlagHamincha120Minutes": "2024-04-24T19:28:53+03:00",
"TzaisGeonim3Point65Degrees": "2024-04-24T19:30:58+03:00",
"TzaisGeonim3Point676Degrees": "2024-04-24T19:31:06+03:00",
"TzaisGeonim3Point7Degrees": "2024-04-24T19:31:13+03:00",
"TzaisGeonim3Point8Degrees": "2024-04-24T19:31:43+03:00",
"TzaisGeonim4Point37Degrees": "2024-04-24T19:34:35+03:00",
"BainHasmashosRT13Point5MinutesBefore7Point083Degrees": "2024-04-24T19:34:49+03:00",
"TzaisGeonim4Point61Degrees": "2024-04-24T19:35:48+03:00",
"TzaisGeonim4Point8Degrees": "2024-04-24T19:36:45+03:00",
"PlagHamincha120MinutesZmanis": "2024-04-24T19:39:04+03:00",
"PlagHamincha26Degrees": "2024-04-24T19:40:37+03:00",
"TzaisGeonim5Point88Degrees": "2024-04-24T19:42:12+03:00",
"TzaisGeonim5Point95Degrees": "2024-04-24T19:42:34+03:00",
"EndCivilTwilight": "2024-04-24T19:42:49+03:00",
"TzaisBaalHatanya": "2024-04-24T19:42:49+03:00",
"BainHasmashosRT2Stars": "2024-04-24T19:44:16+03:00",
"TzaisGeonim6Point45Degrees": "2024-04-24T19:45:06+03:00",
"TzaisGeonim7Point083Degrees": "2024-04-24T19:48:19+03:00",
"TzaisGeonim7Point67Degrees": "2024-04-24T19:51:18+03:00",
"Tzais": "2024-04-24T19:55:33+03:00",
"TzaisGeonim8Point5Degrees": "2024-04-24T19:55:33+03:00",
"TzaisAteretTorah": "2024-04-24T19:56:55+03:00",
"TzaisGeonim9Point3Degrees": "2024-04-24T19:59:40+03:00",
"TzaisGeonim9Point75Degrees": "2024-04-24T20:01:59+03:00",
"EndNauticalTwilight": "2024-04-24T20:13:41+03:00",
"BainHasmashosRT58Point5Minutes": "2024-04-24T20:15:25+03:00",
"Tzais60": "2024-04-24T20:16:55+03:00",
"BainHasmashosRT13Point24Degrees": "2024-04-24T20:20:12+03:00",
"Tzais72": "2024-04-24T20:28:55+03:00",
"Tzais16Point1Degrees": "2024-04-24T20:35:27+03:00",
"Tzais72Zmanis": "2024-04-24T20:36:38+03:00",
"EndAstronomicalTwilight": "2024-04-24T20:45:47+03:00",
"Tzais18Degrees": "2024-04-24T20:45:47+03:00",
"Tzais90": "2024-04-24T20:46:55+03:00",
"Tzais96": "2024-04-24T20:52:55+03:00",
"Tzais19Point8Degrees": "2024-04-24T20:55:44+03:00",
"Tzais90Zmanis": "2024-04-24T20:56:34+03:00",
"Tzais96Zmanis": "2024-04-24T21:03:12+03:00",
"Tzais120": "2024-04-24T21:16:55+03:00",
"Tzais120Zmanis": "2024-04-24T21:29:47+03:00",
"Tzais26Degrees": "2024-04-24T21:31:40+03:00",
"SolarMidnight": "2024-04-25T00:37:49+03:00",
"ShaahZmanisGra": "PT1H6M25.666S",
"TemporalHour": "PT1H6M25.666S",
"ShaahZmanisBaalHatanya": "PT1H7M2.866S",
"ShaahZmanisAteretTorah": "PT1H16M24.233S",
"ShaahZmanis60Minutes": "PT1H16M25.666S",
"ShaahZmanis72Minutes": "PT1H18M25.666S",
"ShaahZmanisMGA": "PT1H18M25.666S",
"ShaahZmanis16Point1Degrees": "PT1H19M29.642S",
"ShaahZmanis72MinutesZmanis": "PT1H19M42.800S",
"ShaahZmanis18Degrees": "PT1H21M12.699S",
"ShaahZmanis90Minutes": "PT1H21M25.666S",
"ShaahZmanis96Minutes": "PT1H22M25.666S",
"ShaahZmanis19Point8Degrees": "PT1H22M51.997S",
"ShaahZmanis90MinutesZmanis": "PT1H23M2.083S",
"ShaahZmanis96MinutesZmanis": "PT1H24M8.511S",
"ShaahZmanis120Minutes": "PT1H26M25.666S",
"ShaahZmanis120MinutesZmanis": "PT1H28M34.222S",
"ShaahZmanis26Degrees": "PT1H28M50.222S",
"SofZmanKidushLevana15Days": "N/A",
"SofZmanKidushLevanaBetweenMoldos": "N/A",
"TchilasZmanKidushLevana3Days": "N/A",
"TchilasZmanKidushLevana7Days": "N/A",
"ZmanMolad": "N/A"
}
}

now i would like to use it in b4x without running a server. i would like to convert the whole library so i can run the function inside b4x OFFLINE.

how much would you charge for it? you can send me pm.

thanx, ilan


EDIT: online live example: https://behindthemath.github.io/KosherZmanim/

EDIT: job is currently given to @tummosoft . If there will be any changes i will update the thread. Thanks 🙏🏻
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
date.toISOString().substr(0, 19)
What is the result of this? What kind of Datestring is it/how does it look like?
 

ilan

Expert
Licensed User
Longtime User
oh sorry @DonManfred you asked for the DateString i read data string.

the date looks like this:

"2024-04-01"

YYYY-MM-DD

it can also include time but this is not important. but the dateformat is important.
 

ilan

Expert
Licensed User
Longtime User
But the code is expecting a 19 bytes long String!?

in the example code above i entered a date including time like this:

2024-04-24T13:14:55

but entering the date alone is good enough as long as it is like this: YYYY-MM-DD (month and day needs to be 2 DIGITS!!)

What is the "output" of this code?

2024-04-24T13:14:55

you can try it here:

B4X:
<!DOCTYPE html>
<html>
<body>

<h1>JavaScript Dates</h1>
<h2>Using new Date()</h2>
<p>Create a new date object with the current date and time:</p>

<p id="demo"></p>

<script>
var date = new Date();
document.getElementById("demo").innerHTML = date.toISOString().substr(0, 19);
</script>

</body>
</html>

enter the code above here:

 

ilan

Expert
Licensed User
Longtime User
Ok thanks @DonManfred. Actually 2 members offer their service i will start with @tummosoft and give him the opportunity to do the job.
If there will be any changes i will update the thread thank you all 🙏🏻
 
Top