### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: UTC Time question  (Read 4887 times)

#### MarkMLl

• Hero Member
• Posts: 2427
##### Re: UTC Time question
« Reply #15 on: August 06, 2020, 10:58:25 pm »
If the system were anything like rational The Meridian would run through Florence.

If trying anything clever, be prepared for rounding errors: TDateTime isn't (always) an extended floating point, and so the further we move from the epoch the worse the precision.

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

#### winni

• Hero Member
• Posts: 2295
##### Re: UTC Time question
« Reply #16 on: August 06, 2020, 11:28:03 pm »
Hi!

Yes  - it is awful with "line zero" : There were hard scientific battles if London or Paris will be the "line zero". There were times, when both lines in their sovereign territory were used. Britania then ruled the waves and had won: Greenwich was now "line zero".

And the second awful thing : The planets and the moons don't behave metric. The bloody earth needs 365.2524 day to surround the sun. And the naughty moon does not have a clear relationship to the sun. The only thing already the old greek knew was that the moon is every 18 years nearly at the same position: The great (moon) year.

And the only (?) try to get a metric time was the french revolution. But the metric time never succeeded. The idea was: The day with 10 hours, the hour with 100 minutes, the minute with 100 seconds. This revolution time was never used. In opposite to the metric french revolution calendar, which had a livetime from 1792 to 1805.

Winni

#### JLWest

• Hero Member
• Posts: 1013
##### Re: UTC Time question
« Reply #17 on: August 06, 2020, 11:35:48 pm »
This time it isn't flight or duration. I want to do an API call for departures and arrivals for about 1000 airports around the world and get as many flights as possible. Doing an API for departures at Berlin at 2:00 am would not yield many flights. Between 9000 and 1000 would a lot better.

Had to included lazutf8sysutils to my use clause.

Works great.

Phoenix = '8/6/2020 14:30:21'
Berlin    = '8/6/2020 23:30:33'

Thanks

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

#### winni

• Hero Member
• Posts: 2295
##### Re: UTC Time question
« Reply #18 on: August 06, 2020, 11:45:18 pm »
Hi!

Nice.

And in some minutes you will have still a "lazy thursday afternoon" but in germany we have a new day. The time goes round and round ...

Winni
« Last Edit: August 06, 2020, 11:49:28 pm by winni »

#### winni

• Hero Member
• Posts: 2295
##### Re: UTC Time question
« Reply #19 on: August 07, 2020, 12:09:20 am »
And don't  be astonished  about timezones with half an hour:
There are even ones of 15 minutes (politics).

Hi!

You are right, but that diminished in the last years.
The only countries I know are Nepal and the Chattham Island (belonging to New Zealand).

The other way round is also a problem:
The whole China - in reality 4 timezones - belong to one timezone: Peking time for sure.
And most parts of the EU belong to Berlin time - in reality 3 timezones.

Winni

#### TRon

• Hero Member
• Posts: 536
##### Re: UTC Time question
« Reply #20 on: August 07, 2020, 09:22:02 pm »
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.

Indeed in that case things work different, but only slightly

Thank you for having taken the time to let me know.

#### JLWest

• Hero Member
• Posts: 1013
##### Re: UTC Time question
« Reply #21 on: August 07, 2020, 09:52:11 pm »
@TRon Thanks for the reply. I expressed the problem very poorly.

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.

Is that right?

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

#### winni

• Hero Member
• Posts: 2295
##### Re: UTC Time question
« Reply #22 on: August 07, 2020, 10:03:58 pm »
Hi and ???

What you gonna do?

That gives you ~ 13:00 h for Phoenix:

showMessage  (DateTimeToStr(NowUTC - 7/24) );

Winni

#### TRon

• Hero Member
• Posts: 536
##### Re: UTC Time question
« Reply #23 on: August 07, 2020, 10:59:31 pm »
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.

Is that right?
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).

By looking at the numbers you have provided I can only tell it isn't enough to be able to calculate, unless the UTC offset of your current timezone/location is -7 ?

#### JLWest

• Hero Member
• Posts: 1013
##### Re: UTC Time question
« Reply #24 on: August 07, 2020, 11:17:19 pm »
yea, I'm in Phoenix and the offset is -7.
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

#### winni

• Hero Member
• Posts: 2295
##### Re: UTC Time question
« Reply #25 on: August 07, 2020, 11:20:43 pm »
Hi and ???

What you gonna do?

That gives you ~ 13:00 h for Phoenix:

showMessage  (DateTimeToStr(NowUTC - 7/24) );

Winni

#### JLWest

• Hero Member
• Posts: 1013
##### Re: UTC Time question
« Reply #26 on: August 07, 2020, 11:37:44 pm »
@Winni

Don't Understand yoir post.

My queston was:

I just ran my program and  NowUTC - 7/24 gives 4:32:14 the Local time is 2:32:14/

Is this right.

Why do we divide by 24?

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

#### winni

• Hero Member
• Posts: 2295
##### Re: UTC Time question
« Reply #27 on: August 07, 2020, 11:44:03 pm »
Hi!

Because the day has 24 hours.

TDateTime works that  way:

The integer part are days.
The fractional part is the time.
Clock 1 h = 1/24
Clock 5 h = 5/24
Clock 24 = 24/24 = 1 = next day

Got it ?

Winni

#### JLWest

• Hero Member
• Posts: 1013
##### Re: UTC Time question
« Reply #28 on: August 07, 2020, 11:53:21 pm »
Yea, Got it.

So in theory I can get the UTC time anywhere with NowUTC +/- offset.
With that I can get the local time somehow.

I think you said UTC time is the same time everywhere in the world.
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

#### winni

• Hero Member
• Posts: 2295
##### Re: UTC Time question
« Reply #29 on: August 08, 2020, 12:45:47 am »
Hi!

Yes. UTC is the same everywhere in the world. That's why the internal flight plans are always UTC - don't get mixed up with different time zones and daylight savings. For the customers they are then converted to local time.

I mad you - quick and dirty - a small international clock for 10 cities around the world plus UTC. It is in the attachment.

Winni