Modules¶
Schengulator is a tool to calculate how many days an individual has been in Schengen countries out of a specified 180-day period.
@author: Penelope How
- class schengulator.SchengenStay(d1=datetime.date(2022, 1, 4), window=180)¶
Bases:
object
Holds all attributes associated with a stay or collection of stays within the Schengen zone (or outside of home country)
- Variables
date1 (datetime.date) – End date
date0 (datetime.date) – Start date
window (int) – Window of evaluation to check stays in Schengen area or stays outside of home country (default=180 days)
stays (list) – List of Stay objects, representing stays within the Schengen zone (or outside of home country)
- addStay(start, end)¶
Add stay (as Stay object)
- Parameters
start (str) – Start date of stay
End (str) – End date of stay
- checkDays(days=90)¶
Check if number of days in Schengen period is less than 90 days within the given 180 day period, based on inputted stays
- Parameters
days (int, optional) – Maximum number of days in Schengen area or out of home country
- Returns
Flag denoting if the number of days in below (True) or above (False) 90 days
- Return type
bool
- getDays()¶
Get number of days in Schengen area (or out of home country) within the given 180 day period, based on inputted stays
- Returns
days_out – Number of days in Schengen area
- Return type
int
- getStartDate()¶
Get start of 180 day period, which is calculated from the inputted date to initialise the SchengenStay object
- Returns
Start date of 180 day period
- Return type
datetime.date
- class schengulator.Stay(start, end)¶
Bases:
object
Holds all attributes atributed to a stay in a country, or a trip away from the home country
- Variables
start (datetime.date) – Start date of stay
end (datetime.date) – End date of stay
- checkStay(d1, d2)¶
Check if any date of stay is within a given date range
- Parameters
d1 (datetime.date) – Start date
d2 (datetime.date) – End date
- Returns
flag – Flag denoting if stay is within (True) or outside (False) of given date range
- Return type
bool
- countStay(d1, d2)¶
Count number of days of stay within a given date range
- Parameters
d1 (datetime.date) – Start date
d2 (datetime.date) – End date
- Returns
count – Number of days of stay that are within given date range
- Return type
int
- getDates()¶
Get all dates within start and end date of stay
- Returns
List of all dates within date range
- Return type
list
- getDelta()¶
Get time delta between start and end date of stay
- Returns
Time delta of date range
- Return type
datetime.delta
- schengulator.checkDaysLeft(stays, d=datetime.date(2022, 1, 4), max_days=90, window=180)¶
Check the number of days left to visit Schengen area (or stay out of home country). Two answers are given - a theoretical leave date and an actual leave date. The theoretical leave date is the remaining number of days that you can stay in the Schengen area, assuming that the 180-day window remains static (i.e. evaluated from the same dates). The actual leave date is the remaining number of days that you can stay in the Schengen area, assuming that the 180-day window is dynamic and moves with the final day of the last recorded stay (i.e. as if your final trip keeps extending day-to-day as you continue to stay in a Schengen country)
- Parameters
stays (list) – List of all past stays e.g. [[start1, end1], [start2, end2]]
d (str/datetime.date) – Date to evaluate from. Today’s date is used if this is not specified (default=datetime.date.today())
max_days (int) – Maximum number of days that can be spent in Schengen area, or out of home country (default=90)
window (int) – Window of evaluation (default=180)
- schengulator.checkStay(staydate, stays, window=180)¶
Check proposed stay is inkeeping with Schengen 90-day rule and past stays in Schengen countries (or out of home country)
- Parameters
staydate (list) – List containing start and end date of proposed stay
stays (list) – List of all past stays i.e. [[start1, end1], [start2, end2]]
- schengulator.getDate(d)¶
Export date as datetime.date, or check if date passed is datetime.date
- Parameters
d (str/datetime.date) – Date
- Returns
Datetime date
- Return type
datetime.date
- schengulator.staysFromCSV(csv_file)¶
Read past stays from CSV
- Parameters
csv_file (str) – File path to CSV file containing past stays
- Returns
stays – List of date strings of start and end of all stays i.e. [[start1, end1], [start2, end2]]
- Return type
list