59-60 second Coordinate issue - coordinates

everyone, who read this.
I found an issue that latitude or longitude of geocoordinate with, for example, 2 minutes and 59 seconds, after converting to decimal format, has value "0.049722", but
2 minutes and 60 seconds has value "0.35", but I thought it must be equal to equal to
3 minutes and 00 seconds, that has value "0.05"
3 minutes and 00 seconds, that has value "0.05"
But again
2 minutes and 61 seconds, that has expected value "0.050278"
Is it global geocoordinate issue or online converter issue?
I use http://the-mostly.ru/konverter_geograficheskikh_koordinat.html

When looking at the source of the respective website, you notice the following line:
if (LAsec==60) {LAsec = 0;LAminutes = LAminutes+1;}
Since LAminutes is still a string, this represents a string concatenation, so 2 is converted to 21 instead of 3.
See: javascript (+) sign concatenates instead of giving sum?
In short, the website is very wrong!
Maybe you should use WolframAlpha for this:
https://www.wolframalpha.com/input/?i=0+deg+2%27+60%22+N,+0+deg+E

Related

What is the correct way to calculate number of DNS queries/second using Get-DnsServerStatistics?

I am trying to figure out how to get the number of DNS queries/second for each domain controller using PowerShell Get-DnsServerStatistics. I copied some of the relevant outputs below.
I try to figure out what is the time period of getting 11793847 "TotalQueries" ?
Under section "TimeStatistics," does the field "TimeElapsedSinceLastClearStatisticsBetweenRestart" with value 00:00:28 means 28 seconds? There is another field "TimeElapsedSinceServerStart" has value 34.01:35:21 and I don't understand what it means? maybe 34 days 1 hour 35 min 21 second?
But if there are 28 seconds with total 11793847 DNS queries. i.e. 421208 queries/second is seems not true in our environment. Could you please help me out?
TimeStatistics:
==============
**TimeElapsedSinceLastClearedStatisticsBetweenRestart 00:00:28**
LastClearTime 9/7/2021 9:33:20 PM
ServerStartTime 9/7/2021 9:33:20 PM
TimeElapsedSinceLastClearedStatistics 34.01:35:21
TimeElapsedSinceServerStartBetweenRestart 00:00:28
**TimeElapsedSinceServerStart 34.01:35:21**
Query2Statistics:
================
TypeAll 1917
TKeyNego 0
TypeOther 897431
**TotalQueries 11793847**
Your assumptions about the time formats are correct. The *BetweenRestart times are the offline times of your DNS service. The time you are looking for is
TimeElapsedSinceLastClearedStatistics - TimeElapsedSinceLastClearedStatisticsBetweenRestart
This is the timespan in which your DNS service was actually answering queries (34.01:34:53). I recommend to parse the timespans into TimeSpan objects using [System.TimeSpan]::Parse("34.01:35:21"), for example. Then you can easily subtract the timespans like shown above.
The resulting timespan object offers you the TotalSeconds member attribute, which you can use for your ratio calculation (your ratio is about 4 queries/s).

How do I convert milliseconds to days, hour, minutes

I tried to do this:
long Plptime = player.getStatistic(Statistic.PLAY_ONE_TICK)*50L; //from ticks to ms(1 tick (20 each sec) by 50 gives aprox the ms)
SimpleDateFormat formatter = new SimpleDateFormat("dd 'days,' HH
'hours and' mm 'minutes'", Locale.getDefault());
Date date = new Date(Plptime);
String result1 = formatter.format(date);
But when it messages the String to the player (minecraft by the way), the hours and days start on 1 while the min start on 0, for example right when someone just joins his playtime will be 01days 01 hours 00 min. Any solutions? Thanks
Java 9 or later
Let’s first declare a couple of helpful constants.
private static final int TICKS_PER_SECOND = 20;
public static final Duration ONE_TICK = Duration.ofSeconds(1).dividedBy(TICKS_PER_SECOND);
Now do:
int ticks = player.getStatistic(Statistic.PLAY_ONE_TICK);
Duration plpTime = ONE_TICK.multipliedBy(ticks);
String result1 = String.format(Locale.ENGLISH, "%02d days %02d hours and %02d minutes",
plpTime.toDays(), plpTime.toHoursPart(), plpTime.toMinutesPart());
System.out.println(result1);
This prints a string like
00 days 17 hours and 08 minutes
Possibly the number of ticks per second (20) is already declared as a constant somewhere in Bukkit, I don’t know. If it is, take that one rather declaring your own.
Java 6, 7 or 8
The toXxxPart methods I used were introduced in Java 9. Without them we need to calculate the individual parts like this:
long days = plpTime.toDays();
plpTime = plpTime.minusDays(days);
long hours = plpTime.toHours();
plpTime = plpTime.minusHours(hours);
long minutes = plpTime.toMinutes();
String result1 = String.format(Locale.ENGLISH, "%02d days %02d hours and %02d minutes",
days, hours, minutes);
The result is the same as above.
Question: How can that work in Java 6 or 7?
The Duration class that I am using is part of java.time, the modern Java date and time API
In Java 8 and later and on newer Android devices (from API level 26, I’m told) java.time comes built-in.
In Java 6 and 7 get the ThreeTen Backport, the backport of the new classes (ThreeTen for JSR 310; see the links at the bottom).
On (older) Android use the Android edition of ThreeTen Backport. It’s called ThreeTenABP. And make sure you import the date and time classes from org.threeten.bp with subpackages.
What went wrong in your code?
Why the hours seem to start at 1 (not 0): It’s your time zone. When you create a Date from your milliseconds, you get the point in time that many milliseconds after the epoch defined as 00:00 UTC on Jan 1, 1970 (which conceptually is quite misleading when the question was when a player joined). If your time zone was 1 hour ahead of UTC in the winter of 1970 (like Central European time, for example), it was already 1 o’clock at the epoch, so the hours count from there.
And since it was January 1, the day is given as 1, of course. Curiously, if you had been in a time zone west of GMT (America/Los_Angeles to give just one example), the date would still have been December 31, 1969 in the first hours after the epoch, so the newly joined player might appear to have been there for 31 days, 16 hours and 00 minutes, for example.
Links
Oracle tutorial: Date Time explaining how to use java.time.
Java Specification Request (JSR) 310, where java.time was first described.
ThreeTen Backport project, the backport of java.timeto Java 6 and 7 (ThreeTen for JSR-310).
ThreeTenABP, Android edition of ThreeTen Backport
Question: How to use ThreeTenABP in Android Project, with a very thorough explanation.

Rexx: increment current time value

Hi I'm running REXX script on ZOC terminal and i want to display current time and ETA like this:
start time 22:44:24
end time 22:56:24
but I don't know how to increment current time ???
maybe to convert time to seconds then increment it and then convert time in seconds back to hh:mm:ss ??
I tried this way but dont know how to convert back time from seconds
intTime= TIME('S')+900
say="start time " TIME()
say="end time " intTime
One way would be along the lines of:-
intTime = TIME('S') + 900
hours = (intTime % 3600) // 24
minutes = (intTime // 3600) % 60
seconds = intTime // 60
endtime = RIGHT(hours,2,'0') || ":" || RIGHT(minutes,2,'0') || ":" || RIGHT(seconds,2,'0')
NOTE!! I don't have access to test this and it's been many years since I've written Rexx or had access. However, I think the basic process would work. That is:-
1) Extract the hours as an integer from the time (catering for the the potential to cross into the next day or days ie the // 24 ()).
2) Extract the minutes, as an integer, from the time, after dropping/subtracting the hours (the remainder of the time divided by hours ie intTime // 3600).
3) Extract the seconds, as an integer, from the time. By obtaining the remaining of diving the time by 60 (will drop hours and minutes).
4) Building the end string as a concatenation of the hours, minutes and seconds. With : as the separator between two values (or surrounding the middle values). The right function to include a leading zero.
You could also try:-
intTime = TIME('S',TIME('S')+900,'S')
That is based upon TIME, which may be Object Rexx. I did also read something mentioning an extended TIME/DATE functionality. However, again that may have been referencing Object Rexx. Although, Mike Colishaw's name was mentioned.
Mike Colishaw, I believe, being the creator of the Rexx programming language.

Length of string results in google apps

I've a function in gApps spreadsheet that takes a dollar figure multiplies by 100 and then returns the length of the string...
function checkWrite(amount) {
amount = amount * 100
amount = amount+'';
var aLength = amount.length;
return(aLength);
Return gives the following results:
amount--length
4. ---- 3
4.01 -- 3
4.02 -- 18
4.03 -- 3
4.04 -- 3
4.05 -- 3
4.06 -- 18
... and so on. I get many correct answers, 3, and some random wrong ones 18.
Can anyone shed some light on what's going on? I'm not great at coding, but I'm pretty sure that results should be consistent anyway.
Most likely the numbers are not rounded as you'd expect. Float point values are not exactly represented as you're thinking. To check that you should return the string representation generated as well, e.g. change the last line to return aLength+' '+amount;
Anyway, what's the usage of such function? If I have any idea on what you use it for, I could suggest some alternative solution.

ASP: convert milliseconds to date

I need to convert a field with milliseconds created by PHP app to a date value. Is there a way to do this using VBScript? or convert to datetime in SQL 2005?
Example: 1113192000 to mm/dd/yyyy hh:mm:ss
Something like the following should work:
Function ConvertPhpToDate(numSeconds)
Dim dEpoch
dEpoch = DateSerial(1970,1,1)
ConvertPhpToDate = DateAdd("s",numSeconds,dEpoch)
End Function
Note, the php time() function returns the number of 'seconds', not milliseconds. http://php.net/manual/en/function.time.php
I think what you are referring to as milliseconds is really the epoch time as returned by the php's time/date functions. You can give this a function a shot to get the epoch time converted to datetime format in ASP:
function epoch2date(myEpoch)
epoch2date = DateAdd("s", myEpoch, "01/01/1970 00:00:00")
end function
Source: http://www.epochconverter.com/epoch/functions.php#asp
msValue = 32312312
dtValue = DateAdd("s", msValue/1000, CDate("1970-01-01 00:00:00"))
Wrap it in a function:
Function TimestampToDate(timestamp)
TimestampToDate = DateAdd("s", timestamp/1000, CDate("1970-01-01 00:00:00"))
End Function
You'll need to have a base time to count the milliseconds from e.g. 1st Jan 1970 or similar.
You then divide the number of milliseconds by 1000 to get the number of seconds - saving the remainder.
Divide the number of seconds by 60 (saving the remainder) to get the number of minutes.
Then 60 again for hours, 24 for days.
Then it get's difficult as you've got leap years to consider. There is another question on this here.
Once you've got your years, days, hours, minutes, seconds and milliseconds you add this to the base date-time to get the date-time represented.
Others have posted code etc. that you might use.