Boost logo

Boost :

Subject: [boost] date libary construction
From: Shamsher Siddiqui (mails.shamshersiddiqui_at_[hidden])
Date: 2013-05-04 10:11:54


i am deeply regretting for not responding your Question and for not
posting the google summer of code Proposal .

my pre semester exams are going on so i was busy in preparing which is
ending on 7 may which is coming tuesday so i will be always not active
during this period but i will try to respond to discussion which happening
on the mailing list .

i am finally sending only the proposal part .

 Proposal for DATE LIBRARY

1)Construction of Date:

According to paper [2] there were many benchmark set but date should be
represented in both ways i.e field and serial .Field and serial
representation have their advantage over each other under certain
operation .

No invalid dates can be entered considering range cheaking ,non existent
date if entered bad_date exception is thrown during the time of
constructing the date.

Constructing constant object for day,week_day.

Date construction concrete structure

<template class date_concrete>

class date_pre

{

//year, month,week day

//constructors

//basic accessors declaration

//conversion accessors

//airthematic operation

//camparison operator for date camparison

}

2) Arithematic Operation On date

Date airthematic can be done on three units i.e day,month,year.In chrono
date ::calendar(Gregorian calendar) length of month and year is not
fixed :

day arithematic

Adding number of days to date until range doesn’t exceed

Implementing last day arithmetic to avoid the bad date excepti

                              Eg.

                                     aug/last/2011 +months(1)= sep/30/2011

                                     aug/31/2000 +months(1)=sep/31/2000
//invalid date bad date excep thrown

   month arithmetic

                                Month arithmetic is quite complex compared
to day arithmetic since number of are not fixed .

 (month day <=28 || month day =last day ) always add month

  month day =29 cheak for leap year and than add month

  Month day>=30 add but don’t add if resulting month is feb

  Using constant objects for month arithmetic.

year arithematic

Always add year to date considering the condition of leap year

Reversal of date back to original date

 Usage of last day during year arithematic

3) InterConversion field representation & serial representation

      Some operation are quite fast on field but airthematic operation are
much faster on serial campared field representation .So it is necessary to
provide the inter-coversion so that it can be easily converted from one
representation to another.

 Constructing bi-directional conversion of serial and field by making use
of memoization optimization techinique.

4)Gregorian calendar implementation

This Gregorian calendar will be a hybrid calendar that support both Julian
and Gregorian calendar with a single discontinuity(the day on which
Gregorian calendar was adopted ).The only difference between gregorian and
julian is leap year calculation and before day of adoption of Gregorian
calendar ,Julian calendar is implemented in this date library.

The concrete draft for implementation for calendar

 template< typename ymd_type ,type name date _int _type >

 class gregorian_calendar {

public :

typedef ymd_type ymd _ type ;

typedef typename ymd_type : : month_type month_ type ;

typedef typename ymd_type : :day_type day_type ;

typedef typename ymd_type : : year_type year_type ;

typedef date_ int _type date_int_type ;

 static unsigned short day_of_week (const ymd _type &ymd ) ;

static int week_number (const ymd_type &ymd ) ;

static date_int_type day_number(const ymd_type &ymd ) ;

static ymd_type from_day_number(date_int_type) ;

static date_int_type julian_day_number(const ymd_type &ymd) ;

static bool is_leap_year(year_type) ;

static unsigned short end_of _month_day( year_type y ,month_type m
) ;

static ymd _ type epoch() ;

static unsigned short days _ i n _week();

};

5)Building date iterator ,date output and date input

     Date Iterator will generate the date based on initial condition and
end.Bidirectional iterator will do all the generation of series of
date.Various iterators which will be implemented are day ,week ,month ,year
Iterator.

  date output same as H. Hinnant.

Questions:

1)could you explain us why do you think a class template date is a good
alternative?

i am using the template class since it will implement the user
extensibility .This is very important feature for developer but not for
normal user because developer likes to customise code it will give them to
add or modify without removing features.

2) What is the expected service of the concrete classes?

     Which concrete representations would you provide?

i have made the concrete class to show some of details of the date library
which i am going to implement .

<template date_concrete>

class date_pre

{

/*year, month,week day

construction of date_field i.e serial and field based reprasentation*/

/*details of constructor

1)date_pre();

//default constructor to initialise the date with the initial default value
set

2)date_pre(year_type year,month_type month,day_type day);

/*this constructor will initialize the date with values given by the user .
but the constructor argument arrangement can be differ according to user or
the country date format used */

3)date_pre(year_type year,month_type month,week_of_month_type
week_number,weekday_type wd);

//this will constructs the date like monday in week 20 of 2013

4)date_pre(special day sp);

//this will day construct the date with the special values like mothers
day ,christmas in year

//basic accessors declaration

//conversion accessors

//airthematic operation

//camparison operator for date camparison

//Coversion of calendar

};

these all same as in H. Hinnant proposal except the conversion of Julian
calendar to gregorian calendar .

3) How would you implement the memoizer for conversions? Would it be thread
safe?

 Could you post an example how your date_pre and gregorian claendar classes
are used?

in summary, how your proposal improc-ves H.H implementation or my prototype?

since pre semester are going so can i answer to this 2 question after
coming tuesday ie 7 may 2013

 sorry again for not answering ur questions i will try to be active on the
mailing list during my pre semester xam

 Thanking You

  Shamsher Ahmed


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk