Georgian date to hijri
date conversion:
Before that you
have to write the new method in global class and call the this method through
global class
static void
Job15(Args _args)
{
date d;
str a,k;
str b;
d=today();
/*a= date2str(d,321,DateDay::Digits2,
DateSeparator::Hyphen, // separator1
DateMonth::Digits2,
DateSeparator::Hyphen, // separator2
DateYear::Digits4);*/
b= Global::NormaltoHijriDate(d);
print b;
pause;
}
Main
code which you have to write new method in global class as:
static str
NormaltoHijriDate(date _transDate)
{
TransDate dt;
int HijriDt;
int HijriMonth;
str Yr,finaldate;
int findate;
CalendarConverter CalendarConverter;
str Hijridat,HijriMnth,HijriYr;
;
dt = _transDate;
CalendarConverter = new
CalendarConverter(PreferredCalendar::Hijri);
HijriDt = CalendarConverter.dayofmth(dt);
HijriMonth = CalendarConverter.mthofyr(dt);
Yr = CalendarConverter.yearStr(dt);
Hijridat = int2str(HijriDt);
HijriMnth = int2str(HijriMonth);
HijriYr = subStr(Yr,1,5);// Sub string is taken as i want to return only two digits
of year you write as subStr(Yr,3,5);
//finaldate =
HijriYr+" " +HijriMnth+" " +Hijridat;
finaldate
= Hijridat+"/"+HijriMnth+"/"+HijriYr;
return finaldate;
}
Date2str
function:
1) strFmt("%1", myDate))
2) date2Str(dateType, 123, -1, -1, -1, -1, -1, -1) this will use the users
regional settings which can be different between users.
3) Most flexible way date2Str(dateType, 123, DateDay::Digits2,
DateSeparator::Slash, DateMonth::Digits2, DateSeparator::Slash,
DateYear::Digits4), change the enum values to your preferred format. Have a
look here: http://msdn.microsoft.com/en-us/library/aa857241.aspx.
2) date2Str(dateType, 123, -1, -1, -1, -1, -1, -1) this will use the users
regional settings which can be different between users.
3) Most flexible way date2Str(dateType, 123, DateDay::Digits2,
DateSeparator::Slash, DateMonth::Digits2, DateSeparator::Slash,
DateYear::Digits4), change the enum values to your preferred format. Have a
look here: http://msdn.microsoft.com/en-us/library/aa857241.aspx.
Example:
void DateTStringConvert()
{
date today=today();
str TodayDate;
;
TodayDate = date2str(
today,321,DateDay::Digits2,DateSeparator::Slash,DateMonth::Digits2,DateSeparator::Slash,DateYear::Digits4);
info(TodayDate );
}
Note :
The function date2str
take following parameters :
1- the date .
2- the date style dmy or ymd or....etc .
3- number of digits for day .
4- separator
5- number of digits for month.
6- separator
7- number of digits for year.
now you can use the date as string
example:
static void date2StrExample(Args _arg)
{
date d = today();
str s;
;
s = date2Str(d, 123, 2, -1, 2, -1, 2);
print "Today's date is " + s;
pause;
}
{
date d = today();
str s;
;
s = date2Str(d, 123, 2, -1, 2, -1, 2);
print "Today's date is " + s;
pause;
}
No comments:
Post a Comment