Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I calculate parking rates over several days when rates are specified daily?

Tags:

c#

algorithm

I have to calculate total billable amounts for card holders, for card based access to car parks. My rate structure looks like this. Each zone in a car park will have a prioritized list of these prices.

public partial class HourlyPrice
{
    public int Id { get; set; }
    public int DayId { get; set; }
    public DateTime StartTime { get; set; }
    public DateTime EndTime { get; set; }
    public int MinHour { get; set; }
    public int MaxHour { get; set; }
    public decimal Price { get; set; }
}

DayId allows for e.g. 'free on Sundays from 13h00'. MinNour and 'MaxHour' allow for 0 to 2 hours is free, where 5 to 6 hours costs R11.00. StartTime and EndTime allow for 'after 18h00 costs R7.00, flat rate'.

My concern is where no multi-day price is specified. When a car enters under one price structure on one day, and exits under another on another day. This looks to me like I will have to sequentially visit each hour parked by the vehicle and accumulate the amount due. This seems a very expensive way of doing things.

Any advice on such an endevour would be greatly appreciated.

like image 720
ProfK Avatar asked Apr 02 '13 07:04

ProfK


People also ask

How much is HDB parking per day?

You can choose Whole Day Parking (24 hours) at $12 per day, or Overnight Parking (valid from 10.30 pm to 7 am the next day) at $5 per night.

How is total parking area calculated?

Find your parking ratio by dividing the number of spaces by the building's square footage (in thousands). For instance, take a 40,000-square-foot building with a 200-space parking lot. Divide 200 (spaces) by 40 (thousand square feet) to find a parking ratio of 5 spaces per 1,000 square feet.

How much does it cost to park overnight at HDB?

For car parks with Night Parking Scheme, short-term parking charges are capped at $5 per night (10:30pm to 7:00am on the following day). Short-term parking is not available at car parks without the Night Parking Scheme.

How much is HDB parking per hour?

HDB Overnight Parking and Other Short-Term Parking Charges $0.60 per half hour for locations outside Central Area. $1.20 per half hour on Monday to Saturday for locations within Central Area (7:00am to 5:00pm). For car parks with Night Parking Scheme, it is capped at $5 per night (10.30pm to 7.00am).


1 Answers

I think this library should solve all your problems:

http://www.codeproject.com/Articles/168662/Time-Period-Library-for-NET

like image 126
Nahum Avatar answered Nov 15 '22 01:11

Nahum