How to use a TimeZoneConverter in p5js

Jimbo

Hallo everyone im now making my own Clock in p5js and want it to change between 3 different timezones but i dont know how it works and i need your help for this matter i would be very happy for your help The Code is as follows:

    let bg;
 function setup() {
createCanvas(windowWidth, windowHeight);
 angleMode(DEGREES);
 textAlign(CENTER);
 background(100);
 }
function draw() {
let hr = hour();
let min = minute();
let sc = second();
selectTimeZone();
background('black');
imageMode(CENTER);
image(bg, width/2, height/2, width, height)
translate(200, 200);
rotate(-90);
//noFill();
//fill(255);
//noStroke();
strokeWeight(8);
stroke(243, 435, 767);
let end=map(sc, 0, 60, 0, 360);
arc(0, 0, 300, 300, 0, end);
strokeWeight(8);
noFill();
stroke(2, 435, 767);
let end2=map(min, 0, 60, 0, 360);
arc(0, 0, 280, 280, 0, end2);
strokeWeight(8);
noFill();
stroke(3, 435, 767);
let end3=map(hr % 12, 0, 12, 0, 360);
arc(0, 0, 260, 260, 0, end3);
push();
rotate(end);
stroke(243, 435, 767);
line(0, 0, 100 ,0);
pop();
push();
rotate(end2);
stroke(2, 435, 767);
line(0, 0, 75 ,0);
pop();
push();
rotate(end3);
stroke(3, 43, 767);
line(0, 0, 50 ,0);
pop();
}
function preload()
{
bg = loadImage('mdvmefeejg331.jpg');
 }
function selectTimeZone() {
sel = createSelect();
sel.position(400,20);
sel.option('Deutschland');
sel.option('Turkey');
sel.option('Iran');
fill(0);
noStroke();
textSize(40);
}
function mySelectEvent() {
country = sel.value();
  }
 

I searched the whole web but didnt find anything about this even no mention in the references Thanks in advance for your help

jstl

I'm not aware of any automatic time zone changing function or library in p5.js. If I were to do this, I would do it manually, which is a huge pain. Here's what I would do:

  1. Wherever you are, look up the difference between your time and UTC.
  2. Make a variable utc with UTC hour (calculate based on your time and the difference between your time and UTC).
  3. Look up the difference between UTC and each of the options on your drop-down menu.
  4. When a certain place is selected, calculate their time based on UTC and whatever the difference is between their time and UTC.
  5. Use that time for your hours.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I use same random background color to fill rectangle in P5js

How to install P5js on windows?

p5js use loop function in main scope

Use p5js functions with node, npm minification

How to overlay a shape on a video in p5js?

How to move an object back and forth in p5js javascript

how to get the texture of a shader in p5js

How to fill text with particles using p5js

How to do a task outside of draw loop in p5js

How to upload image in p5js using React?

How to smooth out the trails of the particles in a p5js simulation

How to return the camera position in p5js?

p5js, How to make the color follow with the array?

how to get the color of a single pixel in p5js

How do I rotate an object in p5js?

Use image uploaded through HTML DOM file uploader in p5js

How to get the speed of an object dragged with the mouse in P5js library

How to drag DOM element inside canvas without going out of canvas with P5js?

How can I read a text file with a custom extension using p5js

How can i reset the deltaTime in my p5js sketch to restart the sketch?

How to change the fill of p5js 3d Geometries

How can I run code in parallel to p5js draw loop?

p5js for loop programming Q: how to make circles bigger and brighter near mouse pointer

How to leave trail in my sketch without deleting the background in p5js?

How do i make my character not go to space in p5js

How can I create a tooltip on mouse over in p5JS?

How do I reverse the animation of a drawing in P5JS (more details in post)

How to iterate over the rows of a table with p5js using table.setNum()

How to use p5/js serial library in google Colab