calculating offer period for subscription

Posted by TheVillageIdiot on Stack Overflow See other posts from Stack Overflow or by TheVillageIdiot
Published on 2010-04-23T04:10:39Z Indexed on 2010/04/23 4:13 UTC
Read the original article Hit count: 317

Filed under:
|
|
|

I'm maintaining a web application which deals with some kind of subscriptions. Users can to renew their subscriptions from 2 months before expiry (not earlier than that). Sometimes user does not renew before expiry and get grace period which is of 3 months. Now he can renew in these 3 months of grace period.

Now the problem part. In the previous transactions of renew requests I have to show what was the offer period for that particular request (subscription start and subscription end period if renew was granted). Things are pretty simple if user renews before expiry, but I'm not able to get things straight if there is grace period specially when the subscriptions is expiring in last months of the year. Also there sometimes calculations go haywire when subscription is ending in jan or feb.

All this is happening because offer period is not saved with the application anywhere (I don't know why). so if subscription is ending in 20 October 2008 and renew application is submitted in 16 January 2009 (because of grace period) the offer period should be 21 October 2008 to 20 October 2009.

© Stack Overflow or respective owner

Related posts about dates

Related posts about algorithm