Re: implementation of islamic (hijri) calendar for Calendar extension

From: Date: Sun, 01 Aug 2004 17:15:41 +0000
Subject: Re: implementation of islamic (hijri) calendar for Calendar extension
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-11790@lists.php.net to get a copy of this message
> these is my contribution to implement islamic (hijri) calendar. > > Waiting for your suggestions. > Without knowing the internals of the hijri calender here are a few generic suggestions: 1) Consider using zend_parse_parameters rather than zend_get_parameters, it'll help furture readability. 2) Rather than combining month/day/year into astring for returning from jdtohijri() consider returning them as an array of values, as string-OR-array depending on optional flag parameter, or return the component pieces by-ref. 3) What's the maximum length of a hijri date string? If it's 10 like the gregorian calender MM/DD/YYYY, then you need to make your temporary buffer be char[11] to hold the terminating NULL. 3a) When dealing with a short buffer it's a good idea to use snprintf() to be absolutely certain you don't overrun. Since you'll be estrdup()ing this call (in RETURN_STRING()) later on anyway, you could just use spprintf() here and pass the return in with a duplicate parameter of 0, but that's splitting hairs. 3b) It'll also avoid an extra strlen() in RETURN_STRING() if you capture the legnth output of sprintf() and pass it into RETURN_STRINGL(). 4) To avoid potential namespace conflicts, it'd help to prefix the internal methods you define in hijri.c with something uniqing (i.e.: php_cal_hijri_SdnToHijri(), php_cal_hijri_HijriToSdn), or speicfy them as 'static' if they will only be used within their local object file. 5) Internal method names should be all lowercase with underscores used for word boundaries. i.e.: SdnToHijri => std_to_hijri. studlyCaps is meant for object method names exported to userspace. 6) How is Hijri pronounced? Is the j hard like english-"Jump", soft like spanish-"Juego", or silent? Just curious on that one... -Sara

« previous php.internals (#11790) next »