Recent

Author Topic: UTC Time question  (Read 10347 times)

MarkMLl

  • Hero Member
  • *****
  • Posts: 6676
Re: UTC Time question
« Reply #60 on: August 08, 2020, 03:51:41 pm »
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.

I was just making the point, and if it's a tutorial it could usefully include examples of how to generate its timezone dataset from definitive information.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: UTC Time question
« Reply #61 on: August 08, 2020, 03:55:16 pm »
"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.
 
« Last Edit: August 08, 2020, 04:03:24 pm by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: UTC Time question
« Reply #62 on: August 09, 2020, 03:10:37 am »
"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.
 

JL, I'd be interested to see if it reports that small city I mentioned earlier, Broken Hill as being in the same timezone as Adelaide or Sydney.  Its in the same state as Sydney but uses Adelaide Time.

Establishing a database would be relatively easy, keeping it current might be a bit harder. On my Linux system I see quite frequent updates to the data on timezones, apparently many places change the days when daylight saving time cuts in or out.  Hmm, wonder where that data comes from ?

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: UTC Time question
« Reply #63 on: August 09, 2020, 03:32:38 am »
JL, I'd be interested to see if it reports that small city I mentioned earlier, Broken Hill as being in the same timezone as Adelaide or Sydney.  Its in the same state as Sydney but uses Adelaide Time.

I'll see what the TZ and TZoffset is for Broken Hill, Adelaide and Sydney. Take me a bit so stay tuned.

You know you right about keeping the TZ Records current.

Just a thought, We have a dataset (Text Records) of say 45,000 - 50,000.

We don't kept all 50,000 current. You would have a form with 1 to 6 clocks (configurable) on the form. The form would make 1 to 6 API calls and display the local times. That can be done with a free subscription to TimeZoneDB.
« Last Edit: August 09, 2020, 04:06:28 am by JLWest »
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: UTC Time question
« Reply #64 on: August 09, 2020, 04:25:20 am »
@abandon
I had Broken Hill  in the archives. So I made it active which forces the API call to TimeZoneDB.

Broken Hill Timezone = ACST
TimeZone offset = 570 That's 9 and half hours LOL.
Adelaide  is the same but Sydney is AEST and 600

|Broken Hill Airport|-32.001388889|141.471666667|BHQ|YBHI|N|ACST|570|
|Adelaide International Airport|-34.945|138.530555556|ADL|YPAD|N|ACST|570|
|Sydney Int'l Airport|-33.946111111|151.177222222|SYD|YSSY|N|AEST|600|
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: UTC Time question
« Reply #65 on: August 09, 2020, 12:39:01 pm »
Broken Hill Timezone = ACST
TimeZone offset = 570 That's 9 and half hours LOL.
Adelaide  is the same but Sydney is AEST and 600
OK, so its is correct, thats a good thing ! And a touch surprising.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: UTC Time question
« Reply #66 on: August 10, 2020, 04:51:45 am »
I made the prototype, should I post it here?

I think the clock should be:
- The UI should be as simple as possible
- It consists of only 2 forms: config form and the form for showing the clocks
- The mainform is the config form
- User can choose how many clocks to be shown
- If user choose 0 clock then it will show the credit page
- The form for the clocks is resizable

Questions:
- Can I use third party graphics library?
- What is the maximum numbers of clocks?
- What should I show on the credit page?
- What is the name of this project?

I quickly made a prototype. Not for now, but later it will be have choose-able skins. Do you guys remember the steampunkclock by @bylaardt? That was awesome.  For better performance I use BGRABitmap, which I believe should have no problem to run on wide range of hardware. To make it easy for beginners to study I use the old-school style, I do not write new class. And I do not optimize the code for performance.

I (later) will try to move the UI and the drawing module away from mainform, so it will be easy to combine with the time zone synchronization code. Here is how to activate the clock:

Code: Pascal  [Select][+][-]
  1.   frmClocks.SetMainform(Self);
  2.   frmClocks.SetLayout(Row, Col);
  3.   frmClocks.Show;

For now, the demo only shows rotating icons. The clocks is not proportional resized, I will fix this issue later. Anyone please try it on different hardware and OSes. Does it work right? Do you have any suggestions?

Note:
To able to compile it, BGRABitmap need to be installed. Here is how to install BGRABitmap:
Lazarus main menu > Package > Online Package Manager > BGRABitmap > Install > From repository

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: UTC Time question
« Reply #67 on: August 10, 2020, 05:27:29 am »
I have a GDrive. If I could figure out how to use it we could post there. I knew how to use it but they changed it.

I think the clock should be:
- The UI should be as simple as possible         <== YES
- It consists of only 2 forms: config form and the form for showing the clocks
- The mainform is the config form
- User can choose how many clocks to be shown
- If user choose 0 clock then it will show the credit page <== Should be ale to
                                                                                          press a small button
                                                                                         to show the credits.

- The form for the clocks is resizable                              <=== Is that needed ???

Questions:
- Can I use third party graphics library?                         <== My vote YES
- What is the maximum numbers of clocks?                    <== I think 6
- What should I show on the credit page?                       <== Me, you, TRon,Winni
- What is the name of this project?                                <== Don't know

On the config of the clocks form.
I would vote for a small red button you press and the credits would popup.

Lower right of each clock would be a small round object like you would use to set the time. 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.

Somewhere on the clock form we show UTC time.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: UTC Time question
« Reply #68 on: August 10, 2020, 05:55:25 am »
- The form for the clocks is resizable                              <=== Is that needed ???

The form and the clocks should be resizable. Some users have 1024 x 768 small screen but others may have 2560 x 1600 large screen. If we use a fix size output, it may look too small or to large on certain screens.

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.

Should not be a problem. I ever made searchable edit/combo box.

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: UTC Time question
« Reply #69 on: August 10, 2020, 06:05:11 am »
OK - resizable it it.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

TRon

  • Hero Member
  • *****
  • Posts: 2435
Re: UTC Time question
« Reply #70 on: August 10, 2020, 06:11:38 am »
- What is the name of this project?                                <== Don't know
Lame suggestion: Clocks around the world-wiser

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: UTC Time question
« Reply #71 on: August 10, 2020, 06:16:35 am »
Sounds good. I'm using it now.

TRon

  • Hero Member
  • *****
  • Posts: 2435
Re: UTC Time question
« Reply #72 on: August 10, 2020, 06:42:09 am »
Sounds good. I'm using it now.
LOL, great !

Lazarus main menu > Package > Online Package Manager > BGRABitmap > Install > From repository
Yeah... uhm.... that poses a problem for me (which I haven't figured out yet)

Established:
Code: [Select]
$ /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...., non-the-wiser  :D
Code: [Select]
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

When i see those kind of things, I always wonder if the time has come to wind the clock forward a couple of eons  :)

edit: Lazarus is one greedy sob, eating away all memory by itself. 1GB swap wasn't enough though increasing it helped overcome the issue.
« Last Edit: August 10, 2020, 07:45:26 am by TRon »

TRon

  • Hero Member
  • *****
  • Posts: 2435
Re: UTC Time question
« Reply #73 on: August 10, 2020, 07:43:14 am »
Anyone please try it on different hardware
arm
Quote
and OSes.
raspbian 32-bit gtk2

Quote
Does it work right?
Seems to work as intended.

Quote
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.

Handoko

  • Hero Member
  • *****
  • Posts: 5131
  • My goal: build my own game engine using Lazarus
Re: UTC Time question
« Reply #74 on: August 10, 2020, 07:47:14 am »
Thank you for the information.

Do you think we should use LazOpenGLContext? I'm afraid BGRABitmap is not optimized for performance.

Using manual canvas drawing should have better performance but the result won't look good, you know jagged lines. I can do anti-aliased lines but will greatly reduce the performance.

Or maybe
It temporary stop drawing when it detect the resizing event.
« Last Edit: August 10, 2020, 08:07:22 am by Handoko »

 

TinyPortal © 2005-2018