first comit
This commit is contained in:
66
test.ipynb
Normal file
66
test.ipynb
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"4\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"import datetime\n",
|
||||
"import calendar\n",
|
||||
"\n",
|
||||
"{\n",
|
||||
" \"data\": \"{\\\"employee_id\\\":105,\\\"from\\\":\\\"2024-02-22\\\",\\\"to\\\":\\\"2024-02-25\\\"}\"\n",
|
||||
"}\n",
|
||||
"#any(grp in group.name.lower() for grp in adminGroups)\n",
|
||||
"workdays = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']\n",
|
||||
"def weekday_count(start, end):\n",
|
||||
" start_date = datetime.datetime.strptime(start, '%Y-%m-%d')\n",
|
||||
" end_date = datetime.datetime.strptime(end, '%Y-%m-%d')\n",
|
||||
" week = {}\n",
|
||||
" days = 0\n",
|
||||
" for i in range((end_date - start_date).days):\n",
|
||||
" day = calendar.day_name[(start_date + datetime.timedelta(days=i+1)).weekday()]\n",
|
||||
" if day in workdays:\n",
|
||||
" days += 1\n",
|
||||
" week[day] = week[day] + 1 if day in week else 1\n",
|
||||
" return days\n",
|
||||
"\n",
|
||||
"from_date = \"2024-02-22\"\n",
|
||||
"to_date = \"2024-02-28\"\n",
|
||||
"\n",
|
||||
"days = weekday_count(from_date, to_date)\n",
|
||||
"print(days)"
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "venv",
|
||||
"language": "python",
|
||||
"name": "python3"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.10.12"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 2
|
||||
}
|
||||
Reference in New Issue
Block a user