Weltzeituhr

58 views
Skip to first unread message

kevin röhl

unread,
Apr 26, 2023, 7:24:06 AM4/26/23
to mementodatabase
Hallo alle miteinander,
Ich hab mir einen kleinen Script für eine Weltzeituhr gebastelt.

var a = new Date()
var b = moment().hour();
var c = b+field("Zeit")-2
var d = moment().minute();
c+":"+d

Das Feld "Zeit" ist für den Unterschied von der GMT.

Mein Problem ist es wenn Uhrzeiten über 24 Uhr kommen
Z.b. Kiritimati (GMT+14) wäre jetzt laut Script 25:13.
Kann mir jemand helfen bitte?

Bill Crews

unread,
Apr 26, 2023, 8:57:58 AM4/26/23
to kevin röhl, mementodatabase
Meine einfache Antwort wäre, einfach eine Änderung wie unten in Rot vorzunehmen.

Meine komplexere Antwort lautet, dass in JavaScript ein Intl-Objekt (Abkürzung des englischen Wortes international) eingebaut ist, das versucht, mit Zeitunterschieden umzugehen, vielleicht mit Sprachunterschieden, vielleicht mit Unterschieden, wie man einen Dezimalpunkt in einer Zahl anzeigt, und so weiter  .  Ich kann das ein wenig falsch liegen.  Ich verweise auf die Behörde unter dem unten stehenden Link.  Aber ich denke, Sie könnten es verwenden, um das Denken für Sie zu übernehmen.

Der einfache Antwortcode...

var a = new Date();
var b = moment().hour();
var c = b+field("time")-2;
var d = moment().minute();
if (c >= 24)
    c -= 24;
c+":"+d;

Der Link für die komplexere Antwort lautet ...

__________

My simple answer would be to just make a modification as in red below.

My more complex answer is that there is an Intl (abbreviation of the English word international) object built into JavaScript that tries to deal with time differences, maybe language differences, maybe differences like how to show a decimal point in a number, and so on. I may have this a little wrong. I defer to the authority at the link below. But I think you could use it to do the thinking for you.

The simple answer code...

var a = new Date();
var b = moment().hour();
var c = b+field("time")-2;
var d = moment().minute();
if (c >= 24)
    c -= 24;
c+":"+d;

The link for the more complex answer is...


--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mementodatabase/a03346d1-19a5-44d1-9081-a42634a30e39n%40googlegroups.com.

kevin röhl

unread,
Apr 30, 2023, 3:58:57 AM4/30/23
to mementodatabase
Wie sehe denn die Komplexe Lösung aus?

What does the complex solution look like?

Bill Crews

unread,
Apr 30, 2023, 11:55:11 AM4/30/23
to kevin röhl, mementodatabase
Obwohl ich seine Absicht verstehe und im Allgemeinen, wie es funktioniert, habe ich das Intl-Objekt nie selbst verwendet, und ich hatte gehofft, dass die Informationen unter diesem Link Ihnen die gewünschte Idee vermitteln würden.

Ich denke, die Idee ist, Code zu schreiben, der für uns selbst normal ist, obwohl wir in verschiedenen Ländern leben, und das Intl-Objekt zu verwenden, damit das, was wir schreiben, für Menschen in anderen Ländern funktioniert.  Für mich sind tausend 1.000,00, aber in Europa sind es meiner Meinung nach 1.000,00.  Und wie übermitteln wir einander Daten, ohne immer die Zeitzone von jemandem nachschlagen und um den richtigen Betrag anpassen zu müssen?  Obwohl ich es nie benutzt habe, denke ich, dass es möglich ist, das Intl-Objekt so zu verwenden, wie es unter diesem Link beschrieben wird.  Wieder ist es...

__________

Though I understand its intent and generally how it works, I've never used the Intl object myself, and I was hoping the information at that link would give you the idea you might want.

I think the idea is to write code that is normal for ourselves, though we live in different countries, and use the Intl object to make what we write work for people in other countries. To me, a thousand  is 1,000.00, but in Europe, I think it's 1.000,00. And how do we convey dates to each other without always having to look up someone's time zone and adjust it by the right amount? Though I've never used it, I think it's possible using the Intl object the way it's described at that link. Again, it's...
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl

Er Mo

unread,
Apr 30, 2023, 2:32:31 PM4/30/23
to mementodatabase
Hallo
Du kannst mal Mementowelt ausbrowiren . Da haben ich die Ortszeit für jede errechnet .

kevin röhl

unread,
May 1, 2023, 12:00:52 AM5/1/23
to mementodatabase
Das ist cool kannst du mir den Script dafür geben?

Er Mo

unread,
May 1, 2023, 1:56:49 AM5/1/23
to mementodatabase
Kopiereb die Bibliothek und öffne die Kopie .Da hast du Zugang zu den Skripten

kevin röhl

unread,
May 1, 2023, 2:33:22 AM5/1/23
to mementodatabase
Aus irgendwelchen Gründen geht das leider nicht. 
Hast du ne Idee?

Er Mo

unread,
May 1, 2023, 4:02:10 AM5/1/23
to mementodatabase
Hallo Kevin
Habe die Bibliothek für das Kopieren freigegeben . Du kannst es versuchen .

Er Mo

unread,
May 1, 2023, 4:09:33 AM5/1/23
to mementodatabase
Meine Vorgangs wieße ist : 1. User bestimmen und desen Eintrag suchen . 2 . Zeitzone ermitteln . 3 . Aktuelle Uhrzeit holen und die Ermitteler Zeizzone abzichen . 4 . Mit der ermittelten Standartzeit die anderen User mit desen Zeizzone umrechen und Schreiben .

Ernst

kevin röhl

unread,
May 1, 2023, 10:33:08 AM5/1/23
to mementodatabase
Vielen lieben Dank 
Reply all
Reply to author
Forward
0 new messages