Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Bromcom VLE to ICS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TheJoeCoder
Bromcom VLE to ICS
Commits
baab7890
Verified
Commit
baab7890
authored
1 year ago
by
TheJoeCoder
Browse files
Options
Downloads
Patches
Plain Diff
Add time editing functionality
parent
750eaef2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
main.py
+17
-0
17 additions, 0 deletions
main.py
with
18 additions
and
0 deletions
.gitignore
+
1
−
0
View file @
baab7890
...
...
@@ -420,5 +420,6 @@ $RECYCLE.BIN/
config.json
patches.json
patches.json.old
input.json
output.ics
\ No newline at end of file
This diff is collapsed.
Click to expand it.
main.py
+
17
−
0
View file @
baab7890
...
...
@@ -98,6 +98,23 @@ def apply_patch(input_lessons: list, patch: dict, week_lookup_table: list) -> li
# Edit the lesson
for
key
,
value
in
patch
[
"
edit
"
].
items
():
lesson
[
key
]
=
value
elif
patch
[
"
type
"
]
==
"
edit_times
"
:
# Edit all lesson times that match the condition
for
lesson
in
input_lessons
:
if
eval_lesson_condition
(
lesson
,
patch
[
"
condition
"
]):
# Get startDate and endDate
start_date
=
datetime
.
datetime
.
strptime
(
lesson
[
"
startDate
"
],
"
%Y-%m-%dT%H:%M:%S
"
)
end_date
=
datetime
.
datetime
.
strptime
(
lesson
[
"
endDate
"
],
"
%Y-%m-%dT%H:%M:%S
"
)
# Get start time and end time, replace in date
if
"
start
"
in
patch
[
"
edit
"
]:
start_time
=
datetime
.
time
.
fromisoformat
(
patch
[
"
edit
"
][
"
start
"
])
start_date
=
start_date
.
replace
(
hour
=
start_time
.
hour
,
minute
=
start_time
.
minute
,
second
=
start_time
.
second
)
if
"
end
"
in
patch
[
"
edit
"
]:
end_time
=
datetime
.
time
.
fromisoformat
(
patch
[
"
edit
"
][
"
end
"
])
end_date
=
end_date
.
replace
(
hour
=
end_time
.
hour
,
minute
=
end_time
.
minute
,
second
=
end_time
.
second
)
# Set new dates
lesson
[
"
startDate
"
]
=
start_date
.
strftime
(
"
%Y-%m-%dT%H:%M:%S
"
)
lesson
[
"
endDate
"
]
=
end_date
.
strftime
(
"
%Y-%m-%dT%H:%M:%S
"
)
elif
patch
[
"
type
"
]
==
"
add
"
:
# Add a lesson
# Build day map
...
...
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