Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
ntpsec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
NTPsec
ntpsec
Commits
9a9a756d
Commit
9a9a756d
authored
8 years ago
by
Eric S. Raymond
Browse files
Options
Downloads
Patches
Plain Diff
Correct precision computation in pyntpdig.
parent
d6b8b3e6
No related branches found
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ntpdig/pyntpdig
+3
-10
3 additions, 10 deletions
ntpdig/pyntpdig
with
3 additions
and
10 deletions
ntpdig/pyntpdig
+
3
−
10
View file @
9a9a756d
...
...
@@ -38,7 +38,7 @@ from __future__ import print_function, division
#
# The one new option in this version is -p, borrowed from ntpdate.
import
sys
,
socket
,
select
,
struct
,
time
,
getopt
,
datetime
import
sys
,
socket
,
select
,
struct
,
time
,
getopt
,
datetime
,
math
try
:
import
ntp.packet
...
...
@@ -192,15 +192,8 @@ def report(packet, json):
t
=
time
.
localtime
(
int
(
packet
.
transmit_timestamp
))
ms
=
int
(
packet
.
transmit_timestamp
*
1000000
)
%
1000000
digits
=
6
#precision = packet.precision
#while True:
# precision *= 10.0
# if precision >= 1:
# break
# digits += 1
#if digits > 6:
# digits = 6;
# Number of decimal digits of precision indicated by the precision field
digits
=
min
(
6
,
-
int
(
math
.
log10
(
2
**
packet
.
precision
)))
date
=
time
.
strftime
(
"
%Y-%m-%d
"
,
t
)
tod
=
time
.
strftime
(
"
%T
"
,
t
)
+
(
"
.%*d
"
%
(
digits
,
ms
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment