برگزیده های پرشین تولز

تاریخ شمسی برای phpbb3?

mba2431

Registered User
تاریخ عضویت
11 مارس 2005
نوشته‌ها
182
لایک‌ها
0
محل سکونت
Roo HOBAB
سلام
من دنبال تاریخ شمسی phpbb3 گشتم ولی فقط تاریخ قمری رو پیدا کردم. آیا می شه اونو به شمسی تبدیل کرد. کدشو زیر می ذارم...
کد:
    ##############################################################
    ## MOD Title: Display Hijriah Date After Current Date on Index Page
    ## MOD Author: zarif < [email protected] > (Zumaidi Zainuddin) http://www.ok2it.com
    ## MOD Description: This mod will display an equivalent Hijriah Date to the Gregorian Date
    ##                  after the display of current date on Index page.
    ## MOD Version: 1.0.0
    ##
    ## Installation Level: Easy
    ## Installation Time: 5 Minutes
    ## Files To Edit: function.php, lang_main.php, page_header.php and index_body.tpl.
    ## Included Files: n/a
    ##############################################################
    ## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
    ## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
    ## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
    ## in our MOD-Database, located at: http://www.phpbb.com/mods/
    ##############################################################
    ## Author Notes: Algoritm for Hijriah date calculation used here is taken from ## http://www.geocities.com/bruastronomy/sunmoon_hijrah_calculator.htm with permisssion.
    ## This method is not 100% accurate that it might differ 1 or 2 days for certain months.
    ## This is due to the fact that  Hijriah date is determined by physical sighting of a new
    ## moon.
    ##
    ##############################################################
    ## MOD History:
    ##
    ##   2003-08-01 - Version 1.0.0
    ##
    ##############################################################
    ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
    ##############################################################

    #
    #-----[ OPEN ]------------------------------------------
    #
    includes/functions.php
    #
    #-----[ FIND ]------------------------------------------
    #
    ?>

    #
    #-----[ BEFORE, ADD ]------------------------------------------
    #
    //
    // Create hijriah date based on timezone;
    //
    function hijriah_date($gmepoch, $tz)
    {
    global $lang;
    $today = getdate($gmepoch + (3600 * $tz));
    $yr = $today[year];
    $d=$today[mday];;
    $m=$today[mon];
    $y=$yr;

    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;
       }
           
    $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;

    return $lang['hari'][$today[wday]].' '. $d .' '.$lang['bulan'][$m].' '.$y;

    }

    #
    #-----[ OPEN ]------------------------------------------
    #
    includes/page_header.php

    #
    #-----[ FIND ]------------------------------------------
    #
    $template->assign_vars(array(
       'SITENAME' => $board_config['sitename'],

    #
    #-----[ AFTER, ADD ]---------------------------------------
    #
    'HIJRAH' => hijriah_date(time(), $board_config['board_timezone']), 

    #
    #-----[ OPEN ]------------------------------------------
    #
    templates/subSilver/index_body.tpl

    #
    #-----[ FIND ]------------------------------------------
    #
    <!-- END switch_user_logged_in -->
       {CURRENT_TIME}   

    #
    #-----[ AFTER, ADD ]---------------------------------------
    #
    ({HIJRAH})

    #
    #-----[ OPEN ]------------------------------------------
    #
    language/lang_english/lang_main.php
    #
    #-----[ FIND ]------------------------------------------
    #
    //
    // That's all, Folks!
    #
    #-----[ BEFORE, ADD ]------------------------------------------
    # 
    // HIJRIAH MOD
    $lang['bulan']['1'] = 'Muharam';
    $lang['bulan']['2'] = 'Safar';
    $lang['bulan']['3'] = 'Rab Awal';
    $lang['bulan']['4'] = 'Rab Akhir';
    $lang['bulan']['5'] = 'Jam Awal';
    $lang['bulan']['6'] = 'Jam Akhir';
    $lang['bulan']['7'] = 'Rejab';
    $lang['bulan']['8'] = 'Syaaban';
    $lang['bulan']['9'] = 'Ramadhan';
    $lang['bulan']['10'] = 'Syawal';
    $lang['bulan']['11'] = 'Zulkaedah';
    $lang['bulan']['12'] = 'Zulhijjah';
    $lang['hari']['0'] = 'Sunday';
    $lang['hari']['1'] = 'Monday';
    $lang['hari']['2'] = 'Tuesday';
    $lang['hari']['3'] = 'Wednesday';
    $lang['hari']['4'] = 'Thursday';
    $lang['hari']['5'] = 'Friday';
    $lang['hari']['6'] = 'Saturday';

    #
    #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
    #
    # EoM
 

mba2431

Registered User
تاریخ عضویت
11 مارس 2005
نوشته‌ها
182
لایک‌ها
0
محل سکونت
Roo HOBAB
سلام
من چندتا الگوریتم پیدا کردم. ببینین بدرد می خوره؟؟؟
کد:
%%
%% This is file `jalali.tex',
%% also known as `ircal.tex',
%% Copyright (C) 2000-2004  Behdad Esfahbod <[email protected]>
%%
%% Provides Iranian Calendar
%%
\newif\ifir@leap
\newif\ifir@kabiseh

\def\ir@today{{%
\countdef\ir@i=0
\countdef\ir@y=1
\countdef\ir@m=2
\countdef\ir@d=3
\countdef\ir@temp=4
\countdef\ir@temptwo=5
\countdef\ir@tempthree=6
\countdef\ir@yModHundred=7
\countdef\ir@dn=8
\countdef\ir@sn=9
\countdef\ir@mminusone=10
\ir@y=\year \ir@m=\month \ir@d=\day
%
\ir@temp=\ir@y
\divide\ir@temp by 100%
\multiply\ir@temp by 100%
\ir@yModHundred=\ir@y
\advance\ir@yModHundred by -\ir@temp\relax
%
\ifodd\ir@yModHundred
   \ir@leapfalse
\else
   \ir@temp=\ir@yModHundred
   \divide\ir@temp by 2\relax
   \ifodd\ir@temp\ir@leapfalse
   \else
      \ifnum\ir@yModHundred=0%
         \ir@temp=\ir@y
         \divide\ir@temp by 400\relax
         \multiply\ir@temp by 400\relax
         \ifnum\ir@y=\ir@temp\ir@leaptrue\else\ir@leapfalse\fi
      \else\ir@leaptrue
      \fi
   \fi
\fi
%
\chardef\ir@gregi31\ifir@leap\chardef\ir@gregii29\else\chardef\ir@gregii28\fi
\chardef\ir@gregiii31\chardef\ir@gregiv30%
\chardef\ir@gregv31\chardef\ir@gregvi30%
\chardef\ir@gregvii31\chardef\ir@gregviii31%
\chardef\ir@gregix30\chardef\ir@gregx31%
\chardef\ir@gregxi30\chardef\ir@gregxii31%
%
\ir@temp=\ir@y
\advance\ir@temp by -17\relax
\ir@temptwo=\ir@temp
\divide\ir@temptwo by 33\relax
\multiply\ir@temptwo by 33\relax
\advance\ir@temp by -\ir@temptwo
\ifnum\ir@temp=32\relax\ir@kabisehfalse
\else
   \ir@temptwo=\ir@temp
   \divide\ir@temptwo by 4\relax
   \multiply\ir@temptwo by 4\relax
   \advance\ir@temp by -\ir@temptwo
   \ifnum\ir@temp=\z@\ir@kabisehtrue\else\ir@kabisehfalse\fi
\fi
%
% In fact irani is equal to the Leap years from a fixed year to the last
% year minus the Kabise years from a fixed year to the last year plus a const.
%
\ir@tempthree=\ir@y                 % Number of Leap years
\advance\ir@tempthree by\m@ne
\ir@temp=\ir@tempthree              % T := (MY-1) div 4
\divide\ir@temp by 4\relax
\ir@temptwo=\ir@tempthree           % T := T - ((MY-1) div 100)
\divide\ir@temptwo by 100\relax
\advance\ir@temp by -\ir@temptwo
\ir@temptwo=\ir@tempthree           % T := T + ((MY-1) div 400)
\divide\ir@temptwo by 400\relax
\advance\ir@temp by \ir@temptwo
\advance\ir@tempthree by -611       % Number of Kabise years
\ir@temptwo=\ir@tempthree           % T := T - ((SY+10) div 33) * 8
\divide\ir@temptwo by 33\relax
\multiply\ir@temptwo by 8\relax
\advance\ir@temp by -\ir@temptwo
\ir@temptwo=\ir@tempthree           %
\divide\ir@temptwo by 33\relax
\multiply\ir@temptwo by 33\relax
\advance\ir@tempthree by -\ir@temptwo
\ifnum\ir@tempthree=32\advance\ir@temp by\@ne\fi % if (SY+10) mod 33=32 then Inc(T);
\divide\ir@tempthree by 4\relax     % T := T - ((SY+10) mod 33) div 4
\advance\ir@temp by -\ir@tempthree
\advance\ir@temp by -137            % T := T - 137  Adjust the value
\ir@temptwo=31
\advance\ir@temptwo by-\ir@temp     % now 31 - T is the farsii
\chardef\ir@irani\ir@temptwo
\chardef\ir@iranii30
\ifir@kabiseh\chardef\ir@iraniii30\else\chardef\ir@iraniii29\fi
\chardef\ir@iraniv31\chardef\ir@iranv31%
\chardef\ir@iranvi31\chardef\ir@iranvii31%
\chardef\ir@iranviii31\chardef\ir@iranix31%
\chardef\ir@iranx30\chardef\ir@iranxi30%
\chardef\ir@iranxii30\chardef\ir@iranxiii30%
%
\ir@dn=0\relax
\ir@sn=0\relax
\ir@mminusone=\ir@m
\advance\ir@mminusone by\m@ne\relax
%
\ir@i=0\relax
\ifnum\ir@i<\ir@mminusone
  \loop
  \advance \ir@i by\@ne\relax
  \advance\ir@dn by \csname ir@greg\romannumeral\ir@i\endcsname
  \ifnum\ir@i<\ir@mminusone\repeat
\fi
\advance \ir@dn by\ir@d
%
\ir@i=1\relax
\ir@sn=\ir@irani
\ifnum\ir@sn<\ir@dn
  \loop
  \advance\ir@i by1\relax
  \advance\ir@sn by\csname ir@iran\romannumeral\ir@i\endcsname
  \ifnum\ir@sn<\ir@dn\repeat
\fi
\ifnum\ir@i<4%
   \ir@m=9\advance\ir@m by\ir@i
   \advance\ir@y by-622\relax
\else
   \ir@m=\ir@i \advance\ir@m by-3\relax
   \advance\ir@y by-621\relax
\fi
\advance\ir@sn by -\csname ir@iran\romannumeral\ir@i%
\endcsname
\ifnum\ir@i =\@ne
  \ir@d=\ir@dn \advance\ir@d by30 \advance\ir@d by-\ir@irani
\else
  \ir@d=\ir@dn \advance\ir@d by-\ir@sn
\fi
%
\xdef\ir@@d{\the\ir@d}%
\xdef\ir@@m{\the\ir@m}%
\xdef\ir@@y{\the\ir@y}%
}%
\let\ir@d\ir@@d
\let\ir@m\ir@@m
\let\ir@y\ir@@y
}

\endinput
%%
%% End of `jalali.tex'.

کد:
using System;

namespace System.Globalization
{
	public class JalaliCalendar : Calendar
	{
		const int era = 0;
		const int monthsInYear = 12;
		const long ticksPerDay = 864000000000L;
		const int daysIn33Years = 365 * 33 + 8;

		static int[] eras = new int[] {0};
		static string[] monthName = {"فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"};
		static int[] leapFlag = {0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,1,0,0,0,1,0,0,0,1,0,0};


		public const int MinJalaliYear = -1096;
		public const int MaxJalaliYear = 2326;

		public JalaliCalendar() : base()
		{
		}

		public static string MonthName(int month)
		{
			return monthName[month - 1];
		}

		public override DateTime AddMonths(DateTime time, int months)
		{
			return time;
		}

		public override DateTime AddYears(DateTime time, int years)
		{
			return time;
		}

		public override int[] Eras
		{
			get { return eras; }
		}

		public override int GetDayOfMonth(DateTime time)
		{
			int year, month, day;
			GetJalaliDate(time, out year, out month, out day);
			return day;
		}

		public override DayOfWeek GetDayOfWeek(DateTime time)
		{
			return (DayOfWeek)(GetDayOfYear(time) % 7);
		}

		public override int GetDayOfYear(DateTime time)
		{
			int d = (int) (time.Ticks / ticksPerDay) - 226529;
			d %= daysIn33Years;
			for (int i=0; i<33; i++)
			{
				int daysInYear = 365 + leapFlag[i];
				if (d < daysInYear)
					return d + 1;
				d -= daysInYear;
			}
			throw new ArgumentOutOfRangeException("time");
		}

		public override int GetDaysInMonth(int year, int month, int era)
		{
			if (month < 7)
				return 31;
			if (month < 12)
				return 30;
			if (IsLeapYear(year, era))
				return 30;
			return 29;
		}

		public override int GetDaysInYear(int year, int era)
		{
			return IsLeapYear(year, era) ? 366 : 365;
		}

		public override int GetEra(DateTime time)
		{
			return era;
		}

		public override int GetMonth(DateTime time)
		{
			int year, month, day;
			GetJalaliDate(time, out year, out month, out day);
			return month;
		}

		public override int GetMonthsInYear(int year, int era)
		{
			return monthsInYear;
		}

		public override int GetYear(DateTime time)
		{
			int year, month, day;
			GetJalaliDate(time, out year, out month, out day);
			return year;
		}

		public override bool IsLeapDay(int year, int month, int day, int era)
		{
			return (month == monthsInYear) && (day > 29) && IsLeapYear(year, era);
		}

		public override bool IsLeapMonth(int year, int month, int era)
		{
			return (month == monthsInYear) && IsLeapYear(year, era);
		}

		public override bool IsLeapYear(int year, int era)
		{
			return leapFlag[year % 33] != 0;
		}

		public override DateTime ToDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int era)
		{
			return new DateTime(year, month, day, hour, minute, second, millisecond);
		}

		public static void GetJalaliDate(DateTime time, out int year, out int month, out int day)
		{
			int d = (int) (time.Ticks / ticksPerDay) - 226529;
			year = (d / daysIn33Years) * 33;
			d %= daysIn33Years;
			for (int i=0; i<33; i++)
			{
				int daysInYear = 365 + leapFlag[i];
				if (d < daysInYear)
					break;
				d -= daysInYear;
				year++;
			}
			if (d < 186)
			{
				month = 1 + d / 31;
				day = 1 + d % 31;
			}
			else 
			{
				d -= 186;
				month = 7 + d / 30;
				day = 1 + d % 30;
			}
		}
	}
}
کد:
Option Explicit 
 
Const Jofst     As Double = 2415018.5 
 
 Function Civil2JDN(dat As  Date) As Double 
    Civil2JDN = dat + Jofst 
End Function 
 
Function JDN2Civil(jdn As Long) As Date 
    JDN2Civil = jdn - Jofst 
End Function 
 
Function Persian2JDN(iYear As Integer, _ 
    iMonth As Integer, _ 
    iDay As Integer) As Long 
     
    Const PERSIAN_EPOCH = 1948321 ' The JDN of 1 Farvardin 1
    Dim epbase  As Long 
    Dim epyear  As Long 
    Dim mdays   As Long 
     
    If iYear >= 0 Then 
        epbase = iYear - 474 
    Else 
        epbase = iYear - 473 
    End If 
     
    epyear = 474 + (epbase Mod 2820) 
    If iMonth <= 7 Then 
        mdays = (CLng(iMonth) - 1) * 31 
    Else 
        mdays = (CLng(iMonth) - 1) * 30 + 6 
    End If 
    Persian2JDN = CLng(iDay) _ 
    + mdays _ 
    + Fix(((epyear * 682) - 110) / 2816) _ 
    + (epyear - 1) * 365 _ 
    + Fix(epbase / 2820) * 1029983 _ 
    + (PERSIAN_EPOCH - 1) 
End Function 
 
Function JDN2Persian(jdn As Long) As Variant 
     
    Dim depoch 
    Dim cycle 
    Dim cyear 
    Dim ycycle 
    Dim aux1, aux2 
    Dim yday 
     
    Dim iYear   As Integer 
    Dim iMonth  As Integer 
    Dim iDay    As Integer 
     
    depoch = jdn - Persian2JDN(475, 1, 1) 
    cycle = Fix(depoch / 1029983) 
    cyear = depoch Mod 1029983 
     
    If cyear = 1029982 Then 
        ycycle = 2820 
    Else 
        aux1 = Fix(cyear / 366) 
        aux2 = cyear Mod 366 
        ycycle = Int(((2134 * aux1) + (2816 * aux2) + 2815) / 1028522) + aux1 + 1 
    End If 
     
    iYear = ycycle + (2820 * cycle) + 474 
    If iYear <= 0 Then 
        iYear = iYear - 1 
    End If 
     
    yday = (jdn - Persian2JDN(iYear, 1, 1)) + 1 
    If yday <= 186 Then 
        iMonth = Ceil(yday / 31) 
    Else 
        iMonth = Ceil((yday - 6) / 30) 
    End If 
    iDay = (jdn - Persian2JDN(iYear, iMonth, 1)) + 1 
     
    JDN2Persian =  Array(iYear, iMonth, iDay) 
End Function 
 
 ' We needed an alternative to Int and Fix.
 ' Int(8.4) = 8, Int(-8.4) = -9
 ' Fix(8.4) = 8, Fix(-8.4) = -8
 ' Ceil(8.4) = 9, Ceil(-8.4) = -9
Private Function Ceil(number As Single) As Long 
    Ceil = -Sgn(number) * Int(-Abs(number)) 
     ' or
     'Ceil = CInt(number + (Sgn(number) * 0.5))
End Function
 

mba2431

Registered User
تاریخ عضویت
11 مارس 2005
نوشته‌ها
182
لایک‌ها
0
محل سکونت
Roo HOBAB
استادان php و برنامه نویسی کمک کنن ... :blink:
 

mba2431

Registered User
تاریخ عضویت
11 مارس 2005
نوشته‌ها
182
لایک‌ها
0
محل سکونت
Roo HOBAB
یعنی چی؟؟؟؟؟؟ :wacko: چند حالت داره
1- کسی بلد نیست!!!! (که فک نکنم)
2- کسی نمی خواد انجام بده (اینم فک نکنم)
3- کسی وقت نداره (اینم عمراً فک کنم)
حالا بقیه شو ولش کنین....
 
بالا