I am using KotlinJS and react, and I have been trying to make a time widget, but I cannot display anything other than est (my time zone) with the toLocaleTimeString() method
import csstype.FontWeight
import csstype.px
import emotion.react.css
import kotlinx.browser.window
import kotlinx.js.timers.setInterval
import org.w3c.xhr.XMLHttpRequest
import react.FC
import react.Props
import react.dom.html.ReactHTML.div
import react.dom.html.ReactHTML.time
import react.useEffect
import react.useState
import kotlin.js.Date
interface ClockWidget : Widget {
var city: String
var continent: String
}
val clockWidgetComponent = FC<ClockWidget> { props ->
var currentTime by useState("")
val city by useState(props.city)
val continent by useState(props.continent)
var difference by useState("")
// var clockResponse: dynamic =
// JSON.parse(httpGet("https://worldtimeapi.org/api/timezone/${continent}/${city}"))
div {
css {
fontWeight = FontWeight.bold
fontSize = 32.px
lineHeight = 39.px
}
// var options = JSON.parse<dynamic>("""{ "timeZone": "${props.continent}/${city}" }""")
+ Date().toLocaleTimeString()
}
useEffect {
// currentTime = clockResponse.datetime.toString()
}
}
+Date().toLocaleTimeString()
this is where i am trying to display the time, but using "PST", or "EST" as the parameter for the method above ^ always displays the same as "en-US"
I tried using the js() method and using js code, but it must be a continuous String, and that wont work for me because I need to insert variables. I also cannot use API because the get request slows down the rest of the page until it is finished.