Calculation of 90 days can be done in 3 cases:
No. I. When a foreigner is entering Ukraine.
Calculation of 90 days is made by an officer of the State Border Service at the checkpoint under the following formula: X (day of entering Ukraine) – Y (180 days). A foreigner is not in breach when he has been on the territory of Ukraine not more than 90 days within this 180 days period. A foreigner is not in breach of the 90 days rule if he has been in Ukraine less than 90 days within this 180 days period. If calculation reveals there are more than 90 day, then entrance to Ukraine is denied.
No. II. When a foreigner is already in Ukraine.
Calculation of 90 days is made by an officer of the State Migration Service under the following formula: X (date for which the fact of overstaying is checked out) – Y (180 days). A foreigner is not in breach of the 90 days rule if he has been in Ukraine less than 90 days within this 180 days period. If calculation reveals there are more than 90 day, then a report on administrative infringement of law is issued.
No. III. When a foreigner is departing from Ukraine.
Calculation of 90 days is made by an officer of the State Border Service at the checkpoint under the following formula: X (day of departure from Ukraine) – Y (180 days). A is not in breach of the 90 days rule if he has been in Ukraine less than 90 days within this 180 days period. If calculation reveals there are more than 90 day, then a report on administrative infringement of law is issued.
Automatic calculation at checkpoints.
Analyzing court cases re overstaying 90 days I found out that (as of 2014) when crossing a checkpoint at the border, information about you is filled into the digital database called “Гарт-1 П” (Gart-1 P) that automatically calculates your 90 days. This “Gart-1 P” has 2 sub-databases called “БД 1-11” (BD 1-11) and “ПТР - 90” (PTR - 90). If this “Gart-1 P” detects you are overstayed, then it signals to the officer and you are in trouble.
P.S. You can read about fines and bans for overstaying in another discussion on this forum.