Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scheduling-system
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SMASCH
scheduling-system
Commits
089b2ce7
Commit
089b2ce7
authored
6 years ago
by
Carlos Vega
Browse files
Options
Downloads
Patches
Plain Diff
added utils module for occasional functions
parent
587db018
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!171
Feature/daily availability
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
smash/web/utils.py
+23
-0
23 additions, 0 deletions
smash/web/utils.py
with
23 additions
and
0 deletions
smash/web/utils.py
0 → 100644
+
23
−
0
View file @
089b2ce7
# coding=utf-8
from
django.utils
import
timezone
import
datetime
,
time
def
timeit
(
method
):
def
timed
(
*
args
,
**
kw
):
ts
=
time
.
time
()
result
=
method
(
*
args
,
**
kw
)
te
=
time
.
time
()
if
'
log_time
'
in
kw
:
name
=
kw
.
get
(
'
log_name
'
,
method
.
__name__
.
upper
())
kw
[
'
log_time
'
][
name
]
=
int
((
te
-
ts
)
*
1000
)
else
:
print
'
%r %2.2f ms
'
%
\
(
method
.
__name__
,
(
te
-
ts
)
*
1000
)
return
result
return
timed
def
get_today_midnight_date
():
today
=
timezone
.
now
()
today_midnight
=
datetime
.
datetime
(
today
.
year
,
today
.
month
,
today
.
day
,
tzinfo
=
today
.
tzinfo
)
return
today_midnight
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