الانتقال إلى المحتوى

How to set deviation? in arabic hijrah


abdul_twab

Recommended Posts

الموضوع من قبل ألا وهو الانحراف (الاختلاف) بين تقويم أوراكل الهجري وبين دورة القمر الفعلية والتي نستخدمها لتحديد عدد أيام الشهر الهجري ولكن هذا الاختلاف لا يوجد عند أوراكل فقط ولكن حتى عندنا نحن المسلمين في تقويمنا الهجري وكذلك عند شركة مايكروسوفت ، وأقصد بالاختلاف أن اليوم مثلاً 13/12/2001م الموافق 28/9/1422هـ هذا هو التاريخ الفعلي الهجري المقابل لهذا التاريخ الميلادي ، أما لو رجعت للدالة الخاصة بأوراكل ستجد أن اليوم هو 27/9/1422هـ وهذا يعني وجود يوم فارق بين التقويم الهجري الفعلي وبين تقويم أوراكل (أعتقد لو أن الأخوة رجعوا لتقويم مايكروسوفت سيجدوا وجود هذا الاختلاف في بعض الأشهر لذلك مايكروسوفت أعطي إمكانية ضبط هذا الاختلاف في التاريخ حتى 7 أيام ) ....
لتصحح أوراكل هذا الاختلاف يتم استخدام ما يسمى بـnls calendar utility lxegen وذلك بإتباع الخطوات التالية (تم تجربة ذلك على جهاز خادم يحتوي على oracle enterprise 8i ، وبحثت في إمكانية تطبيقها على قاعدة البيانات الشخصية ولم أتمكن من ذلك ) ...
(1) إغلاق قاعدة البيانات .
(2) بواسطة الـ MS DOS PROPMT يتم تغيير مسار العمل كما يلي :
>CD\ ..$ORACLE_HOME\OCOMMON\NLS
ثم
..$ORACLE_HOME\OCOMMON\NLS > EDIT LXECAL.NLT
ثم داخل هذا الملف نكتب ما يلي :
define calendar
calendar_name = "arabic hijrah"

define calendar_deviation
deviation_data = {
<"dec-16-2001 ad">:1
}
enddefine calendar_deviation
enddefine calendar

*** ملاحظات مهمة جداً :-
تعويض الانحراف بالزيادة دائماً يكون في الأيام الميلادية المقابلة للأيام الهجرية التالية(29 و30 و 31 من الشهر ) مع العلم أن ذلك فيه شيء من عدم الصحة ولكن أعتقد الأكثر استخداماً في هذه الأيام هو اليوم 30 لأننا قد نرغب في جعل شهر 29 يوماً فقط بدلاً من 30 يوم فنضيف يوم لليوم الميلادي المقابل لليوم 30 هجري فيصبح اليوم الهجري 1 من الشهر التالي .
أما تعويض الانحراف بالنقص فيتم في اليوم الميلادي المقابل لليوم 1 من الشهر الهجري وذلك لتحويل شهر هجري من 29 يوم لـ 30 يوم وذلك بإضافة 11 لطرح يوم أو 12 لطرح يومين وهكذا .
هذه العمليات لا بد من إجرائها في وقتها المناسب مع ملاحظة أن كل عمليات تعويض الانحراف بالزيادة والنقص لا بد من وضعها في ملف واحد وذلك بتكرار سطر الـ DEVIATION DATA حسب الحاجة .

(3) ننفذ هذا الأمر ونحن في نفس المكان

…..$ORACLE_HOME\OCOMMON\NLS > LXEGEN

يتم بعد تنفيذ هذا الأمر بدون أخطاء عمل إنشاء لملف له الاسم LXECALAH.NLB ولو نظرت عليه الآن تحت مسارنا ستجده بالفعل موجود .

(4) الآن قم بتشغيل قاعدة البيانات وجرب استخدام الدالة التي كنا نستخدمها في تحويل التاريخ ستجد أن شهر رمضان أصبح 29 يوماً .
(5) سيلاحظ الأخوة أن هذا الموضوع لم يضبط كاملاً من أوراكل حتى الآن لذلك ستلاحظوا وجود أخطاء في منتهى الغرابة ، أرجو منكم أن تجربوا هذا الأمر في حالات مختلقة وستلاحظوا ما أقول .
--------------------------------------------------------------------------------------

ناخد مثال للحالة :-
شهر 10 هجري ، كان عدد أيامه في تقويم أوراكل 29 يوم ، ولكن شاءت الأقدار والشهر دا كان 30 يوم ،فكيف يتم تحويل هذا الشهر إلى 30 يوم ؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟؟

وليكن تاريخ هذه الأيام كما يلي :-

** 29/10/1422 هـ تقابل 15/6/2001 م
** 01/11/1422 هـ يقابل 16/6/2001 م
** 02/11/1422 هـ يقابل 17/6/2001 م

***** ما هو المطلوب هنا المطلوب تحويل الأمر إلى ما يلي :-

** 29/10/1422 هـ تقابل 15/6/2001 م
** 30/10/1422 هـ يقابل 16/6/2001 م
** 01/11/1422 هـ يقابل 17/6/2001 م

إذا لعمل ما سبق المفترض أن نطرح يوم من التاريخ المقابل للتاريخ الميلادي 16/6/2001 م لكي يصبح 30/10/1422 هـ بدلاً من
01/11/1422 هـ ، لكن عملية الطرح لا تتم مباشرة بطرح يوم لكن تتم بإضافة 11 يوم لطرح يوم و 12 يوم لطرح يومين وهكذا ، إذا سيكون سطر الطرح كما يلي :
<”JUN-16-2001 AD”>:11

------------------------------------------------------------------------------------------
Arabic Hijrah Calendar - FAQ


CONTENTS
--------

1.How to set Calendar to "Arabic Hijrah" ?
2.How to display both Hijrah and Gregorian dates in the same select statement?
3.What is Calendar Deviation?
4.How to set deviation?


Questions & Answers
----------------------------

1.How to set Calendar to "Arabic Hijrah" ?

Answer
------

Set NLS_CALENDAR parameter in one of the following ways:

1. In the Current session :
SQL> alter session set NLS_CALENDAR="Arabic Hijrah" ;

2. All applications for a specific client:
Set NLS_CALENDAR Variable in client OS environment.
<e.g: On NT: set variable in the registry
On Unix: set UNIX environment variable in .profile/.cshrc>

3. Within SQL function:
SQL> select to_char(sysdate,'day dd month yyyy','nls_calendar=''arabic hijrah''')
from dual ;

References
----------

[NOTE:30772.1] Init.ora Parameter "NLS_CALENDAR" Reference Note


2.How to display both Hijrah and Gregorian dates in the same select statement?

Answer
------
select
to_char(sysdate,'day dd month yyyy','nls_calendar=''Arabic Hijrah'''),
to_char(sysdate,'day dd month yyyy','nls_calendar=''English Hijrah'''),
to_char(sysdate,'day dd month yyyy','nls_calendar=''gregorian''')
from dual ;

to make things a bit more clear:

alter session set nls_calendar = 'Arabic Hijrah';
gives the names of the Hijrah months in Arabic
so you client needs to be configured to display Arabic. -> [NOTE:179133.1]

alter session set nls_calendar = 'English Hijrah';
gives the names of the Hijrah months in english.

alter session set nls_calendar = 'gregorian';
gives the names of the Gregorian months (jan-feb-etc).

If you want the names of the Gregorian months in Arabic then please
see [NOTE:264280.1] Incorrect NLS_DATE_LANGUAGE for Arabian Countries

References
----------

[bUG:1302683]


3.What is Calendar Deviation?

Answer
------
Since Hijrah month is based on the moon complete revolution around the sun, Hijrah
Calendar has different number of days in a year than Gregorian; therefore some manual
deviation adjustement might be needed for the conversion to/from Gregorian. In other
words HIJRAH calendar is Lunar based, corrections need to be made every so often.

[NOTE:130551.1] Conversion Algorithm of Gregorian Date to Arabic (Hijra) Date

4.How to set deviation?

Answer
------
1. Shutdown the database

2. Edit/create lxecal.nlt (lxecal.dat in Oracle7) in $ORACLE_HOME/ocommon/nls.
(you find an example in $ORACLE_HOME/ocommon/nls/demo)
This example makes the known adjustments needed between Gregorian
years 2000 and 2004:

DEFINE calendar

calendar_name = "Arabic Hijrah"

deviation_data = {
<"MAY-05-2000 ad">:1
<"AUG-30-2000 ad">:1
<"NOV-26-2000 ad">:11
<"JAN-25-2001 ad">:11
<"Feb-24-2001 ad">:1
<"MAR-25-2001 ad">:11
<"JUN-22-2001 ad">:1
<"JUL-21-2001 ad">:11
<"AUG-20-2001 ad">:1
<"OCT-17-2001 ad">:1
<"NOV-15-2001 ad">:11
<"JAN-14-2002 ad">:11
<"FEB-13-2002 ad">:1
<"MAR-14-2002 ad">:11
<"OCT-07-2002 ad">:1
<"NOV-05-2002 ad">:11
<"DEC-05-2002 ad">:1
<"JAN-03-2003 ad">:11
<"FEB-02-2003 ad">:1
<"JUN-30-2003 ad">:11
<"JUL-30-2003 ad">:1
<"AUG-28-2003 ad">:11
<"SEP-27-2003 ad">:1
<"JUN-18-2004 ad">:11
<"JUL-18-2004 ad">:1
<"AUG-16-2004 ad">:11
<"SEP-15-2004 ad">:1
<"OCT-14-2004 ad">:11
}
ENDDEFINE calendar_deviation

ENDDEFINE calendar


Notes: * Gregorian date specified in the deviation should correspond to one of
29th, 30th or 31th days of the hijrah calendar.
* Numbers greater than 10 are used to subtract days, e.g:
11 --> subtract one day, 12 --> subtract two days ...etc

3. Run the NLS Calendar Utility lxegen to register your modification to Oracle calendar
system, this utility generates lxecalah.nlb file in the same directory mentioned above.

4. startup the database.




If you want to substract dates, please also see to
[bUG:2215017] SUBTRACTING DAYS FROM ARABIC HIJRA DATE DOES NOT WORK

For 9i this bug is logged:
[bUG:2749165] NOT ABLE TO ADJUST THE HIJRAH CALENDAR ANYMORE IN 9.X

You need patch 9204 to be able to adjust the calendar.

There are also these backports:

windows NT/2000 9.2.0.3 Patch2. / patch set nr 2973634
HP-UX 64 bit 9.2.0.3 / Patch nr 2749165



References
----------

Oracle8i National Language Support Guide

these 2 bugs, both closed as "not a bug":
[bUG:583924] NLS:HIJRAH CALENDAR DEVIATION DOES NOT WORK PROPERLY
[bUG:2215017] SUBTRACTING DAYS FROM ARABIC HIJRA DATE DOES NOT WORK

Bugs still open for 10g:
[bUG:2964132] TO_DATE GIVES ORA-01841 WITH HIJRAH CALENDAR

[NOTE:130551.1] Conversion Algorithm of Gregorian Date to Arabic (Hijra) Date
[NOTE:264280.1] Incorrect NLS_DATE_LANGUAGE for Arabian Countries

http://www.math.nus.edu.sg/aslaksen/calend...ar/islamic.html

The Umm al-Qura Calendar of Saudi Arabia
http://www.phys.uu.nl/~vgent/islam/mecca/ummalqura.htm

[NOTE:241047.1] The Priority of NLS Parameters Explained.
[NOTE:158577.1] NLS_LANG Explained (How does Client-Server Character Conversion Work?)
[NOTE:179133.1] The correct NLS_LANG in a Windows Environment

For further NLS / Globalization information you may start here:
[NOTE:150091.1] Globalization Technology (NLS) Library index

_____________________.doc

رابط هذا التعليق
شارك

الف شكر ، لكن الشي المعمول به في الشركات في عملية التحويل من هجري الى ميلادي هي انشاء جدول يشمل التاريخ الميلادي والهجري في انا واحد ولايمكن ان يحصل خطا في عملية التحويل لانها دقيقة جداً

رابط هذا التعليق
شارك

  • بعد 5 شهور...
  • بعد 3 شهور...
  • بعد 1 سنة...
  • بعد 5 سنة...
  • بعد 10 شهور...

شكراً جزيلاً عمل جبار لو ممكن تعطين lxecal.nlt جديد للعربية سعودية
و بنسبة إلى 10G
After creating your lexical file you should copy it in %ORACLE_HOME%/nls folder
and then run below nls calendar utility lxegen command from operating systems command to execute lexical file on database.
%ORACLE_HOME%\bin\lxegen %ORACLE_HOME%\nls\file_name.nlt

after executing this command it will generate new file in nls folder with extension .nlb

رابط هذا التعليق
شارك

انضم إلى المناقشة

يمكنك المشاركة الآن والتسجيل لاحقاً. إذا كان لديك حساب, سجل دخولك الآن لتقوم بالمشاركة من خلال حسابك.

زائر
أضف رد على هذا الموضوع...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   تمت استعادة المحتوى السابق الخاص بك.   مسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

جاري التحميل
×
×
  • أضف...

برجاء الإنتباه

بإستخدامك للموقع فأنت تتعهد بالموافقة على هذه البنود: سياسة الخصوصية