Posted by sinasalek on February 22, 2010 at 8:52am
Jump to:
| Project: | Calendar Systems |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | task |
| Priority: | normal |
| Assigned: | sinasalek |
| Status: | closed (fixed) |
| Issue tags: | 6.x-1.3 Roadmap |
Issue Summary
I'm going to use the Algorithm shared by Khaled Al-Shamaa
Comments
#1
Grerat Work and an equally vital project.
Congratulations for making it happen.
#2
You may also have a look at this #242965: Add support for pluggable calendars in Date API
#3
Thanks @Marat for mentioning.
I also have a question you may know. where are you from and what do you usually call your calendar system? Arabic , Islamic or Hijri ? Are arab countries call it with different names?
About the code, you code is easier to use but is it as accurate as the one i'm implementing?
PS : If you can put more information about your calendar system here http://groups.drupal.org/node/10607 that would be quite useful.
#4
Hi @sinasalek, I am from Saudi Arabia and the Hijri calender is the official calendar used by the government. We commonly call it 'Hijri' but not sure about other arab countries. I would say hijri is most likely used.
Regarding to the code, I didn't write it myself I just copied and pasted there. I am not a programmer so my contribution is just useless. Sorry for that.
The accuracy of hijri date would never be achieved because it depends on the moon sighting and where it is born, which a religious issue. Ummulqura (the official calender in Saudi Arabia www.ummulqura.org.sa) and islamic finder (www.islamicfinder.org) are well known reference for hijri calender and they just used calculation.
It might be simple, just replace the date using any conversion code. In addition to the codes mentioned in my previous comment, there are several more can be used, I pasted them with the header to be clear who wrote them.
<?php
/*
* +------------------------------------------------------------------------------+
* ICalendar : Arabic calendar class project
* +------------------------------------------------------------------------------+
* Disclaimer Notice(s)
*
* This class is based on the work of Johannes Thomann from the Orientalisches
* Seminar der Universitنt Zürich (<a href="http://www.ori.unizh.ch/" title="http://www.ori.unizh.ch/" rel="nofollow">http://www.ori.unizh.ch/</a>)
*
* The use of any code included into this website is prohibed without a written
* authorisation from the author. This class is released for Educational purpose.
*
*
* +------------------------------------------------------------------------------+
* Updates
* +------------------------------------------------------------------------------+
* 2002 : first release of the class written by Hatem
* 4/09/2002; 10:04 : updated copyright and original algorithm author name
* thanks to Nadim Attari (acenad at intnet dot mu).
* 2/01/2007 : Update to support arabic utf-8
* +------------------------------------------------------------------------------+
* Todos
* +------------------------------------------------------------------------------+
*
* The current implementation is 100% compatible with Um-Al-Qura algorithm
* however a manual fix is required to get the exact date, which is at +/- 1day
*
* +------------------------------------------------------------------------------+
* @author Ben Yacoub Hatem <hatem at php dot net>
* @website <a href="http://phpmagazine.net
*" title="http://phpmagazine.net
*" rel="nofollow">http://phpmagazine.net
*</a> +------------------------------------------------------------------------------+
*/
class ICalendar {
/**
* @param encoding windows-1256 or utf-8
*/
var $encoding = 'utf-8';
var $ac_date = array(
'year' => "",
'month' => "",
'monthname' => "",
'day' => "",
'dayname' => ""
);
var $ac_date_g = array(
'year' => "",
'month' => "",
'monthname' => "",
'day' => "",
'dayname' => ""
);
var $year;
var $month;
var $day;
var $monthname;
var $dayname;
var $julianday;
var $AC_Adaynames = array(
'0' => "الأحد",
'1' => "الاثنين",
'2' => "لثلاثاء",
'3' => "الأربعاء",
'4' => "الخميس",
'5' => "الجمعة",
'6' => "الأحد"
);
var $AC_Gdaynames = array(
'0' => "Sunday",
'1' => "Monday",
'2' => "Tuesday",
'3' => "Wednesday",
'4' => "Thirsday",
'5' => "Friday",
'6' => "Saturday"
);
var $AC_AMonthName = array(
'1' => "محرم",
'2' => "صفر",
'3' => "ربيع الأول",
'4' => "ربيع الثاني",
'5' => "جمادة الأول",
'6' => "جمادة الثاني",
'7' => "رجب",
'8' => "شعبان",
'9' => "رمضان",
'10' => "شوال",
'11' => "ذو القعدة",
'12' => "ذو الحجة"
);
/*
Returns True if is an islamic Leap Year
@param $ayear : a year !==0.
*/
function IslamicLeapYear($aYear)
{
if ((((11 * $aYear) + 14) % 30) < 11)
return true;
else
return false;
}
/*
Returns Last day in month during year on the Islamic calendar.
@param $ayear : a year !==0.
*/
function LastDayOfIslamicMonth ($Year, $aMonth)
{
if ((($aMonth % 2) == 1) or (($aMonth == 12) and IslamicLeapYear($aYear)))
return 30;
else
return 29;
}
/*
Constructs a day with a given year, month, and day.
@param aYear a year !== 0
@param aMonth a month between 1 and 12
@param aDate a date between 1 and 31
*/
function Ac_Day($aYear, $aMonth, $aDate)
{
$this->year = $aYear;
$this->month = $aMonth;
$this->acdate = $aDate;
}
/*
Convert from Georgian date to Islamic date.
@param GYear a year !== 0
@param GMonth a month between 1 and 12
@param GDate a date between 1 and 31
*/
function GregorianToIslamic($GYear, $GMonth, $GDay)
{
$y = $GYear;
$m = $GMonth;
$d = $GDay;
if (( $y > 1582 ) || (( $y == 1582 ) && ( $m > 10 )) || (( $y == 1582 ) && ( $m == 10 ) && ( $d > 14 )))
{
$jd = (int)(( 1461 * ( $y + 4800 + (int)(( $m - 14 ) / 12 )))/ 4) + (int)(( 367 * ( $m - 2 - 12 * ((int)(( $m - 14 ) / 12)))) / 12) - (int)(( 3 * ((int)(( $y + 4900+ (int)(( $m - 14) / 12) ) / 100))) / 4)+ $d - 32075;
} else {
$jd = 367 * $y - (int)(( 7 * ( $y + 5001 + (int)(( $m - 9 ) / 7))) / 4) + (int)(( 275 * $m) / 9) + $d + 1729777;
}
$this->julianday = $jd;
$this->ac_date[dayname] = $this->Ac_getDayName( $jd % 7 );
$l = $jd - 1948440 + 10632;
$n = (int)(( $l - 1 ) / 10631);
$l = $l - 10631 * $n + 354;
$j = ( (int)(( 10985 - $l ) / 5316)) * ( (int)(( 50 * $l) / 17719)) + ( (int)( $l / 5670 )) * ( (int)(( 43 * $l ) / 15238 ));
$l = $l - ( (int)(( 30 - $j ) / 15 )) * ( (int)(( 17719 * $j ) / 50)) - ( (int)( $j / 16 )) * ( (int)(( 15238 * $j ) / 43 )) + 29;
$m = (int)(( 24 * $l ) / 709 );
$d = $l - (int)(( 709 * $m ) / 24);
$y = 30 * $n + $j - 30;
$this->ac_date[year] = $y;
$this->ac_date[month] = $m;
$this->ac_date[day] = $d;
$this->ac_date[monthname] = $this->Ac_getMonthName($m);
return $this->ac_date;
}
/*
Convert from Islamic date to Georgian date.
@param IYear a year !== 0
@param IMonth a month between 1 and 12
@param IDate a date between 1 and 31
*/
function IslamicToGregorian($IYear, $IMonth, $IDay)
{
$y = $IYear;
$m = $IMonth;
$d = $IDay;
$jd = (int)((11*$y+3)/30)+354*$y+30*$m-(int)(($m-1)/2)+$d+1948440-385;
$this->julianday = $jd;
$this->ac_date_g[dayname] = $this->Ac_getGDayName( $jd % 7 );
if ($jd> 2299160 )
{
$l=$jd+68569;
$n=(int)((4*$l)/146097);
$l=$l-(int)((146097*$n+3)/4);
$i=(int)((4000*($l+1))/1461001);
$l=$l-(int)((1461*$i)/4)+31;
$j=(int)((80*$l)/2447);
$d=$l-(int)((2447*$j)/80);
$l=(int)($j/11);
$m=$j+2-12*$l;
$y=100*($n-49)+$i+$l;
} else {
$j=$jd+1402;
$k=(int)(($j-1)/1461);
$l=$j-1461*$k;
$n=(int)(($l-1)/365)-(int)($l/1461);
$i=$l-365*$n+30;
$j=(int)((80*$i)/2447);
$d=$i-(int)((2447*$j)/80);
$i=(int)($j/11);
$m=$j+2-12*$i;
$y=4*$k+$n+$i-4716;
}
$this->ac_date_g[day] = $d;
$this->ac_date_g[month] = $m;
$this->ac_date_g[year] = $y;
$this->ac_date_g[monthname] = $this->Ac_getGMonthName($m);
return $this->ac_date_g;
}
/**
Returns the Julian day
@return the year
*/
function Ac_getJulianDay()
{
return $this->julianday;
}
/**
Returns the year of this day
@return the year
*/
function Ac_getYear()
{
return $this->year;
}
/**
Returns the month of this day
@return the month
*/
function Ac_getMonth()
{
return $this->month;
}
/**
Returns the name of the day
@return the day name
*/
function Ac_getDayName($aDay)
{
switch ($aDay)
{
case 0: $day = $this->AC_Adaynames[0];
break;
case 1: $day = $this->AC_Adaynames[1];
break;
case 2: $day = $this->AC_Adaynames[2];
break;
case 3: $day = $this->AC_Adaynames[3];
break;
case 4: $day = $this->AC_Adaynames[4];
break;
case 5: $day = $this->AC_Adaynames[5];
break;
case 6: $day = $this->AC_Adaynames[6];
break;
}
switch($this->encoding) {
case 'utf-8': // convert to utf-8
$day = $this->iconvWin2UTF($day);
break;
default: // do nothing
case 'windows-1256':
break;
}
return $day;
}
/**
Returns the English name of the day
@return the day name
*/
function Ac_getGDayName($aDay)
{
switch ($aDay)
{
case 0: return $this->AC_Gdaynames[0];
break;
case 1: return $this->AC_Gdaynames[1];
break;
case 2: return $this->AC_Gdaynames[2];
break;
case 3: return $this->AC_Gdaynames[3];
break;
case 4: return $this->AC_Gdaynames[4];
break;
case 5: return $this->AC_Gdaynames[5];
break;
case 6: return $this->AC_Gdaynames[6];
break;
}
}
/**
Returns the name of the islamic month
@return the day name
*/
function Ac_getMonthName($aMonth)
{
switch ($aMonth)
{
case 1: $month = $this->AC_AMonthName[1];
break;
case 2: $month = $this->AC_AMonthName[2];
break;
case 3: $month = $this->AC_AMonthName[3];
break;
case 4: $month = $this->AC_AMonthName[4];
break;
case 5: $month = $this->AC_AMonthName[5];
break;
case 6: $month = $this->AC_AMonthName[6];
break;
case 7: $month = $this->AC_AMonthName[7];
break;
case 8: $month = $this->AC_AMonthName[8];
break;
case 9: $month = $this->AC_AMonthName[9];
break;
case 10: $month = $this->AC_AMonthName[10];
break;
case 11: $month = $this->AC_AMonthName[11];
break;
case 12: $month = $this->AC_AMonthName[12];
break;
}
switch($this->encoding) {
case 'utf-8': // convert to utf-8
$month = $this->iconvWin2UTF($month);
break;
default: // do nothing
case 'windows-1256':
break;
}
return $month;
}
/**
Returns the month number
@return the day name
*/
function Ac_getGMonthName($aMonth)
{
switch ($aMonth)
{
case 1: return 1;
break;
case 2: return 2;
break;
case 3: return 3;
break;
case 4: return 4;
break;
case 5: return 5;
break;
case 6: return 6;
break;
case 7: return 7;
break;
case 8: return 8;
break;
case 9: return 9;
break;
case 10: return 10;
break;
case 11: return 11;
break;
case 12: return 12;
break;
}
}
/**
Returns the date of this day
@return the date
*/
function Ac_getDate()
{
return $this->year;
}
/**
Returns a day that is a certain number of days away from
this day
@param n the number of days, can be negative
@return a day that is n days away from this one
*/
function Ac_addDays($n)
{
}
/**
Returns the number of days between this day and another
day
@param other the other day
@return the number of days that this day is away from
the other (>0 if this day comes later)
*/
function Ac_daysFrom($Dayother)
{
}
/**
* Convert windows-1256 to utf-8 - require iconv
*/
function iconvWin2UTF($text) {
$codetable = array();
$table = '30,%1E,31,%1F,32,%20,33,%21,34,%22,35,%23,36,%24,37,%25,38,%26,39,%27,40,%28,41,%29,42,%2A,43,%2B,44,%2C,45,-,46,.,47,%2F,48,0,49,1,50,2,51,3,52,4,53,5,54,6,55,7,56,8,57,9,58,%3A,59,%3B,60,%3C,61,%3D,62,%3E,63,%3F,64,%40,65,A,66,B,67,C,68,D,69,E,70,F,71,G,72,H,73,I,74,J,75,K,76,L,77,M,78,N,79,O,80,P,81,Q,82,R,83,S,84,T,85,U,86,V,87,W,88,X,89,Y,90,Z,91,%5B,92,%5C,93,%5D,94,%5E,95,_,96,%60,97,a,98,b,99,c,100,d,101,e,102,f,103,g,104,h,105,i,106,j,107,k,108,l,109,m,110,n,111,o,112,p,113,q,114,r,115,s,116,t,117,u,118,v,119,w,120,x,121,y,122,z,123,%7B,124,%7C,125,%7D,126,%7E,127,%7F,128,%E2%82%AC,129,%D9%BE,130,%E2%80%9A,131,%C6%92,132,%E2%80%9E,133,%E2%80%A6,134,%E2%80%A0,135,%E2%80%A1,136,%CB%86,137,%E2%80%B0,138,%D9%B9,139,%E2%80%B9,140,%C5%92,141,%DA%86,142,%DA%98,143,%DA%88,144,%DA%AF,145,%E2%80%98,146,%E2%80%99,147,%E2%80%9C,148,%E2%80%9D,149,%E2%80%A2,150,%E2%80%93,151,%E2%80%94,152,%DA%A9,153,%E2%84%A2,154,%DA%91,155,%E2%80%BA,156,%C5%93,157,%E2%80%8C,158,%E2%80%8D,159,%DA%BA,160,%C2%A0,161,%D8%8C,162,%C2%A2,163,%C2%A3,164,%C2%A4,165,%C2%A5,166,%C2%A6,167,%C2%A7,168,%C2%A8,169,%C2%A9,170,%DA%BE,171,%C2%AB,172,%C2%AC,173,%C2%AD,174,%C2%AE,175,%C2%AF,176,%C2%B0,177,%C2%B1,178,%C2%B2,179,%C2%B3,180,%C2%B4,181,%C2%B5,182,%C2%B6,183,%C2%B7,184,%C2%B8,185,%C2%B9,186,%D8%9B,187,%C2%BB,188,%C2%BC,189,%C2%BD,190,%C2%BE,191,%D8%9F,192,%DB%81,193,%D8%A1,194,%D8%A2,195,%D8%A3,196,%D8%A4,197,%D8%A5,198,%D8%A6,199,%D8%A7,200,%D8%A8,201,%D8%A9,202,%D8%AA,203,%D8%AB,204,%D8%AC,205,%D8%AD,206,%D8%AE,207,%D8%AF,208,%D8%B0,209,%D8%B1,210,%D8%B2,211,%D8%B3,212,%D8%B4,213,%D8%B5,214,%D8%B6,215,%C3%97,216,%D8%B7,217,%D8%B8,218,%D8%B9,219,%D8%BA,220,%D9%80,221,%D9%81,222,%D9%82,223,%D9%83,224,%C3%A0,225,%D9%84,226,%C3%A2,227,%D9%85,228,%D9%86,229,%D9%87,230,%D9%88,231,%C3%A7,232,%C3%A8,233,%C3%A9,234,%C3%AA,235,%C3%AB,236,%D9%89,237,%D9%8A,238,%C3%AE,239,%C3%AF,240,%D9%8B,241,%D9%8C,242,%D9%8D,243,%D9%8E,244,%C3%B4,245,%D9%8F,246,%D9%90,247,%C3%B7,248,%D9%91,249,%C3%B9,250,%D9%92,251,%C3%BB,252,%C3%BC,253,%E2%80%8E,254,%E2%80%8F';
$tablex = explode(',', $table);
for($i=0; $i<count($tablex); $i++) {
$codetable[$tablex[$i]] = $tablex[$i+1];
$i++;
}
$converted = '';
for($i=0; $i<strlen($text); $i++) {
$ix = ord($text[$i]);
if (isset($codetable[$ix])) {
$converted.=$codetable[$ix];
} else {
$converted.= $text[$i];
}
}
return rawurldecode($converted);
//*/
//return iconv('windows-1256','utf-8',$text);
}
}
?>
or this class
<?php
////////////////////////////////////Disclaimer////////////////////////////////////////////
///This library has been wrote by : Anas Reslan Bahsas if you are going to use it //
///please dont remove this line . //
///you have to add this class to a asp.net web project to work well. // //
///I will be grateful to receive any commments or suggestion to anasbahsas@hotmail.com
///Downloadable version can be found at "www.codeproject.com/KB/datetime/hijrigregorianclass.aspx" //
//////////////////////////////////////////////////////////////////////////////////////////
using System;
using System.Web;
using System.Diagnostics;
using System.Globalization;
using System.Data;
using System.Collections;
namespace Bahsas
{
/// <summary>
/// Summary description for Dates.
/// </summary>
public class Dates
{
private HttpContext cur;
private const int startGreg=1900;
private const int endGreg=2100;
private string[] allFormats={"yyyy/MM/dd","yyyy/M/d","dd/MM/yyyy","d/M/yyyy","dd/M/yyyy","d/MM/yyyy","yyyy-MM-dd","yyyy-M-d","dd-MM-yyyy","d-M-yyyy","dd-M-yyyy","d-MM-yyyy","yyyy MM dd","yyyy M d","dd MM yyyy","d M yyyy","dd M yyyy","d MM yyyy"};
private CultureInfo arCul;
private CultureInfo enCul;
private HijriCalendar h;
private GregorianCalendar g;
public Dates()
{
cur = HttpContext.Current;
arCul=new CultureInfo("ar-SA");
enCul=new CultureInfo("en-US");
h=new HijriCalendar();
g=new GregorianCalendar(GregorianCalendarTypes.USEnglish);
arCul.DateTimeFormat.Calendar=h;
}
/// <summary>
/// Check if string is hijri date and then return true
/// </summary>
/// <param name="hijri"></param>
/// <returns></returns>
public bool IsHijri(string hijri)
{
if (hijri.Length<=0)
{
cur.Trace.Warn("IsHijri Error: Date String is Empty");
return false;
}
try
{
DateTime tempDate=DateTime.ParseExact(hijri,allFormats,arCul.DateTimeFormat,DateTimeStyles.AllowWhiteSpaces);
if (tempDate.Year>=startGreg && tempDate.Year<=endGreg)
return true;
else
return false;
}
catch (Exception ex)
{
cur.Trace.Warn("IsHijri Error :"+hijri.ToString()+"\n"+ex.Message);
return false;
}
}
/// <summary>
/// Check if string is Gregorian date and then return true
/// </summary>
/// <param name="greg"></param>
/// <returns></returns>
public bool IsGreg(string greg)
{
if (greg.Length<=0)
{
cur.Trace.Warn("IsGreg :Date String is Empty");
return false;
}
try
{
DateTime tempDate=DateTime.ParseExact(greg,allFormats,enCul.DateTimeFormat,DateTimeStyles.AllowWhiteSpaces);
if (tempDate.Year>=startGreg && tempDate.Year<=endGreg)
return true;
else
return false;
}
catch (Exception ex)
{
cur.Trace.Warn("IsGreg Error :"+greg.ToString()+"\n"+ex.Message);
return false;
}
}
/// <summary>
/// Return Formatted Hijri date string
/// </summary>
/// <param name="date"></param>
/// <param name="format"></param>
/// <returns></returns>
public string FormatHijri(string date ,string format)
{
if (date.Length<=0)
{
cur.Trace.Warn("Format :Date String is Empty");
return "";
}
try
{
DateTime tempDate=DateTime.ParseExact(date,allFormats,arCul.DateTimeFormat,DateTimeStyles.AllowWhiteSpaces);
return tempDate.ToString(format,arCul.DateTimeFormat);
}
catch (Exception ex)
{
cur.Trace.Warn("Date :\n"+ex.Message);
return "";
}
}
/// <summary>
/// Returned Formatted Gregorian date string
/// </summary>
/// <param name="date"></param>
/// <param name="format"></param>
/// <returns></returns>
public string FormatGreg(string date ,string format)
{
if (date.Length<=0)
{
cur.Trace.Warn("Format :Date String is Empty");
return "";
}
try
{
DateTime tempDate=DateTime.ParseExact(date,allFormats,enCul.DateTimeFormat,DateTimeStyles.AllowWhiteSpaces);
return tempDate.ToString(format,enCul.DateTimeFormat);
}
catch (Exception ex)
{
cur.Trace.Warn("Date :\n"+ex.Message);
return "";
}
}
/// <summary>
/// Return Today Gregorian date and return it in yyyy/MM/dd format
/// </summary>
/// <returns></returns>
public string GDateNow()
{
try
{
return DateTime.Now.ToString("yyyy/MM/dd",enCul.DateTimeFormat);
}
catch (Exception ex)
{
cur.Trace.Warn("GDateNow :\n"+ex.Message);
return "";
}
}
/// <summary>
/// Return formatted today Gregorian date based on your format
/// </summary>
/// <param name="format"></param>
/// <returns></returns>
public string GDateNow(string format)
{
try
{
return DateTime.Now.ToString(format,enCul.DateTimeFormat);
}
catch (Exception ex)
{
cur.Trace.Warn("GDateNow :\n"+ex.Message);
return "";
}
}
/// <summary>
/// Return Today Hijri date and return it in yyyy/MM/dd format
/// </summary>
/// <returns></returns>
public string HDateNow()
{
try
{
return DateTime.Now.ToString("yyyy/MM/dd",arCul.DateTimeFormat);
}
catch (Exception ex)
{
cur.Trace.Warn("HDateNow :\n"+ex.Message);
return "";
}
}
/// <summary>
/// Return formatted today hijri date based on your format
/// </summary>
/// <param name="format"></param>
/// <returns></returns>
public string HDateNow(string format)
{
try
{
return DateTime.Now.ToString(format,arCul.DateTimeFormat);
}
catch (Exception ex)
{
cur.Trace.Warn("HDateNow :\n"+ex.Message);
return "";
}
}
/// <summary>
/// Convert Hijri Date to it's equivalent Gregorian Date
/// </summary>
/// <param name="hijri"></param>
/// <returns></returns>
public string HijriToGreg(string hijri)
{
if (hijri.Length<=0)
{
cur.Trace.Warn("HijriToGreg :Date String is Empty");
return "";
}
try
{
DateTime tempDate=DateTime.ParseExact(hijri,allFormats,arCul.DateTimeFormat,DateTimeStyles.AllowWhiteSpaces);
return tempDate.ToString("yyyy/MM/dd",enCul.DateTimeFormat);
}
catch (Exception ex)
{
cur.Trace.Warn("HijriToGreg :"+hijri.ToString()+"\n"+ex.Message);
return "";
}
}
/// <summary>
/// Convert Hijri Date to it's equivalent Gregorian Date and return it in specified format
/// </summary>
/// <param name="hijri"></param>
/// <param name="format"></param>
/// <returns></returns>
public string HijriToGreg(string hijri,string format)
{
if (hijri.Length<=0)
{
cur.Trace.Warn("HijriToGreg :Date String is Empty");
return "";
}
try
{
DateTime tempDate=DateTime.ParseExact(hijri,allFormats,arCul.DateTimeFormat,DateTimeStyles.AllowWhiteSpaces);
return tempDate.ToString(format,enCul.DateTimeFormat);
}
catch (Exception ex)
{
cur.Trace.Warn("HijriToGreg :"+hijri.ToString()+"\n"+ex.Message);
return "";
}
}
/// <summary>
/// Convert Gregoian Date to it's equivalent Hijir Date
/// </summary>
/// <param name="greg"></param>
/// <returns></returns>
public string GregToHijri(string greg)
{
if (greg.Length<=0)
{
cur.Trace.Warn("GregToHijri :Date String is Empty");
return "";
}
try
{
DateTime tempDate=DateTime.ParseExact(greg,allFormats,enCul.DateTimeFormat,DateTimeStyles.AllowWhiteSpaces);
return tempDate.ToString("yyyy/MM/dd",arCul.DateTimeFormat);
}
catch (Exception ex)
{
cur.Trace.Warn("GregToHijri :"+greg.ToString()+"\n"+ex.Message);
return "";
}
}
/// <summary>
/// Convert Hijri Date to it's equivalent Gregorian Date and return it in specified format
/// </summary>
/// <param name="greg"></param>
/// <param name="format"></param>
/// <returns></returns>
public string GregToHijri(string greg,string format)
{
if (greg.Length<=0)
{
cur.Trace.Warn("GregToHijri :Date String is Empty");
return "";
}
try
{
DateTime tempDate=DateTime.ParseExact(greg,allFormats,enCul.DateTimeFormat,DateTimeStyles.AllowWhiteSpaces);
return tempDate.ToString(format,arCul.DateTimeFormat);
}
catch (Exception ex)
{
cur.Trace.Warn("GregToHijri :"+greg.ToString()+"\n"+ex.Message);
return "";
}
}
/// <summary>
/// Return Gregrian Date Time as digit stamp
/// </summary>
/// <returns></returns>
public string GTimeStamp()
{
return GDateNow("yyyyMMddHHmmss");
}
/// <summary>
/// Return Hijri Date Time as digit stamp
/// </summary>
/// <returns></returns>
public string HTimeStamp()
{
return HDateNow("yyyyMMddHHmmss");
}
/// <summary>
/// Compare if the Hijri date between other financial year and return True if within , False in not within
/// </summary>
/// <param name="dt">Data Table contain start date and end date ,,start date is the first column in table , end date is the second column in table</param>
/// <param name="fromDate"></param>
/// <param name="endDate"></param>
/// <returns></returns>
/// <summary>
/// Compare two instaces of string date and return indication of thier values
/// </summary>
/// <param name="d1"></param>
/// <param name="d2"></param>
/// <returns>positive d1 is greater than d2,negative d1 is smaller than d2, 0 both are equal</returns>
public int Compare(string d1,string d2)
{
try
{
DateTime date1=DateTime.ParseExact(d1,allFormats,arCul.DateTimeFormat,DateTimeStyles.AllowWhiteSpaces);
DateTime date2=DateTime.ParseExact(d2,allFormats,arCul.DateTimeFormat,DateTimeStyles.AllowWhiteSpaces);
return DateTime.Compare(date1,date2);
}
catch (Exception ex)
{
cur.Trace.Warn("Compare :"+"\n"+ex.Message);
return -1;
}
}
}
}
?>
or may be utilizing the Hijri date extension in Jooomla at http://extensions.joomla.org/extensions/core-enhancements/date-a-time/1740.
#5
@sinasalek, is there any news about adding Hijri date to this module? I am really looking forward to see it. Thank you.
This might help http://en.wikipedia.org/wiki/Islamic_calendar and http://www.gita.ir/products/calendar/gadget.aspx
#6
I'm very busy with a project right now, but i'll implement it the first chance it get. probably within the next two months or even sooner.
#7
Good news everyone, the hijri calendar system is under development, there is going to be a new alpha release quite soon :)
#8
I am very glad to hear that, thanks @sinasalek!
#9
Keep up the good work.!
#10
Finally the first Beta release is available http://drupal.org/node/817192
#11
Fill free to open this issue again, if you had any problem
#12
Automatically closed -- issue fixed for 2 weeks with no activity.
#13
I installed Hijri as a default calendar system. It works perfect. And I'd like to have a block with today's date.
for example
<?php$today = date("F j, Y");
PRINT "$today";
?>
But this produces a date formated in Gregorian, not in Hijri. Could you help me please?
#14
Please do not post unrelated question on an already closed issue!
Also you should use drupal format_date function instead
#15
Marked