Is there a way to get the UTC time of say Berlin.Yes, by looking up the timezone (UTF) offset of Berlin.
I have the local time in Phoenix and I know the current time offset Berlin.Depends on what you mean exactly by time offset. is that he UTF time offset ?
I can't see a way to determine the UTC time in Berlin. Usually provided by means of a database, or more correctly using a lang/long map/database of the world
So for Berlin right now it's CEST 7200,1That is problematic because that would mean you need to use yet another timezone offset, namely cest, which is UTC + 2.
Is there a way to get the UTC time of say Berlin.
I have the local time in Phoenix and I know the current time offset Berlin.
I can't see a way to determine the UTC time in Berlin.
Thanks.
UTC Time location 1 = Local Time Location 1 + UTC time offset location 1It is perhaps confusing but I wrote down the complete calculation because that way you can always calculate every value when you only have two values to work with.
UTC Time location 2 = Local Time Location 2 + UTC time offset location 2
Absolute UTC time duration = UTC Time location 2 - UTC Time location 1
This is confusing.
I don't see anything to convert a TDT to UTCSee winni's answer.
Berlin is now 2 hours before UTC (daylight saving)
BerlinTime := NowUtC + 2.0/24.0 ;
Arizona is 7 hours behind UTC.
No daylight saving execpt the Navajo Nation (6 hours)
PhoenixTime := NowUTC - 7.0/24.0
That's the whole secret.
Winni
It's 1308 in Phoenix. What is the local time in Berlin (1008).
All I have is the time code and offset of Berlin. CEST and 7200,1.Again, see winni's answer in case you wish to keep it simple.
And don't be astonished about timezones with half an hour:There are even ones of 15 minutes (politics).
And don't be astonished about timezones with half an hour:There are even ones of 15 minutes (politics).
This time it isn't flight or duration.Ah ok. In that case I'm sorry with regards to my reply, as I initially had the impression that your question(s) where (still) related to duration.
So I just ran the NowUTC - 7.0/24.0 and it returms 2:48:22 8/8/2020 which seems strange because it's 12:48:22 Local time.Sorry in case I missed it but I am unable to tell without knowing where exactly you are located (or what UTC offset your current location has).
Is that right?
Hi and ???
What you gonna do?
That gives you ~ 13:00 h for Phoenix:
showMessage (DateTimeToStr(NowUTC - 7/24) );
Winni
> There are even ones of 15 minutes (politics).
The only countries I know are Nepal and the Chattham Island (belonging to New Zealand).
"// Convert the local UTC Offset string to an integer value15 minutes = 15 minutes * 60 seconds per minute = 900 seconds
there_UTCOffSet := there_UTCOffsetAsString.ToInt64;"
Wouldn't this have to be converted to a float to handle 15, 30 and 45 minuets?
ThanksNo thanks required for providing some inspiration in case it helps.
Ah, no you would'tI wouldn't what exactly ?
On first read of you code I thought you would have to convert to Float. Then I read it again and realized you don't divide anywhere. By staying in seconds all the way it handles the odd second's offset 15, 30, and 45.Ah ok. dumb me could have figured that out himself but somehow missed that you had seen "the light" during your post.
I think I can convert this to a function and pass an index of the record which is carried in a listbox. The function would pass back a string of there_UTCOffSet.Sure, that should be possible. In case that gives you troubles then please post some code and state what you wish to do with what data exactly and for sure we can come up with a function that works for your case.
Am I correct in thinking that there_UTCoffset is the UTC time of the offset owner. i.e. Berlin.That line of thought is absolutely correct.
Actually your code is pretty slick.Thank you the compliment.
Not saying I won't have any trouble but I think I have a good handle on this now, between you and Winni.In case not then feel free to ask. I'm sure we're not the only ones who would be able to help you out in case of troubles.
You know with the data I have 45,000 airports with Lat/Lon, timezone and timezone offset I could build a pretty big world wide clock. All I need is a clock graphic with movable hands. A little code and my data. You know who is really slick with graphics is handako. I think I found my next project.That could indeed be a very fun project to do. These days there are plenty of websites that are able to do something similar but I find it usually much nicer to be able to do something like that using my own code.
It would make a good tutorial and code example on the Date and time functions in FPC/Lazuras.For sure it would.
I didn't follow this thread but I heard there will be a collaborative project and my skill may be needed, that's awesome. I'm in. I should start looking for some ideas on this weekend.
Have a good weekend!
Are we going to argue about credits. handako will have the hardest job building the graphics. Then I would have the most time culling 45.000 reccords.
There is also a 15min (actually 45min) increment going up a little west of the centre of Australia. But only about 6 people live there and 2 of those don't have watches.
https://en.wikipedia.org/wiki/Eucla,_Western_Australia#Time_zone
Population 53. Wp doesn't indicate how many of those are named "Bruce".
MarkMLl
So we need a reliable table to download.Iana ? https://www.iana.org/time-zones
Does anybody know one?
You would be surprised at what else they don't know !
You should inform your gvernment.
They don't know about that:
https://info.australia.gov.au/about-australia/facts-and-figures/time-zones-and-daylight-saving (https://info.australia.gov.au/about-australia/facts-and-figures/time-zones-and-daylight-saving)
Seriously, as you drive across there, you pass two big signs saying to adjust your clocks by, from memory, 45 minutes and then an hour and 15 minutes. And probably not spoken to anyone in those time zones !
Davo
IANAs allways up to date - but you have all the computing by yourself.
I am looking for a "ready to use" table.
Hi!
IANAs allways up to date - but you have all the computing by yourself.
I am looking for a "ready to use" table.
Winni
IANAs allways up to date - but you have all the computing by yourself.
I am looking for a "ready to use" table.
If you get something off-the-shelf you'll have difficulty protecting your IP since you haven't added any value.
Are we really concerned about protecting the IP. I thought we would make one as a tutorial example of the Date and time functions. Post it on the form for anyone to use.
"As your airport table contains latitude and logitude we can check with PointInPolygon to which zone a city belongs. But we have no info about daylight ."
Yes, we do.
I have a Airport text file with 24,000 cities with Lat/Lon and a subscription to TimezoneDB. I do an API call to TimezoneDB and they give me the current Timezone and timezone offset including daylight savings. Cost $5 a month unlimited use. I just ran my 24,000 records thru.
You can get a free subscription but your limited to 1 API call a second.
But why not implement the "The Time Zone Database" (tz or zoneinfo) it has the UTC offsets, and daylight-saving rules.
Broken Hill Timezone = ACSTOK, so its is correct, thats a good thing ! And a touch surprising.
TimeZone offset = 570 That's 9 and half hours LOL.
Adelaide is the same but Sydney is AEST and 600
- The form for the clocks is resizable <=== Is that needed ???
Press it and a listbox with the 50,000 cities would appear with a Tedit below the listbox. The Tedit would allow an incidental search of the listbox.
- What is the name of this project? <== Don't knowLame suggestion: Clocks around the world-wiser
Sounds good. I'm using it now.LOL, great !
Lazarus main menu > Package > Online Package Manager > BGRABitmap > Install > From repositoryYeah... uhm.... that poses a problem for me (which I haven't figured out yet)
$ /home/apps/fpc/3.2.0/bin/arm-linux/fpcres --version
fpcres - resource file converter, version 2.0 [2020/06/08], FPC 3.2.0
Host platform: Linux - arm
Copyright (c) 2008 by Giulio Bernardi.
lazarus.pp(165,1) Error: Can't call the resource compiler "/home/apps/fpc/3.2.0/bin/arm-linux/fpcres", switching to external mode
Anyone please try it on different hardwarearm
and OSes.raspbian 32-bit gtk2
Does it work right?Seems to work as intended.
Do you have any suggestions?On resizing things flicker a lot, panel name is visible as redrawing of the bitmaps takes place. You an see this pi-3b+ struggle with drawing the images the larger the form becomes.
Do you think we should use LazOpenGLContext? I'm afraid BGRABitmap is not optimize for performance.Hmz.. that could perhaps be an option.
i make a png of what I have in mind.