آژانس هواپیماییexchanging

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

شروع موضوع توسط mba2431 ‏14 ژانویه 2008 در انجمن phpBB - پی‌اچ‌پی بی‌بی

  1. mba2431

    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 
     
  2. mba2431

    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\[email protected]
    \newif\[email protected]
    
    \def\[email protected]{{%
    \countdef\[email protected]=0
    \countdef\[email protected]=1
    \countdef\[email protected]=2
    \countdef\[email protected]=3
    \countdef\[email protected]=4
    \countdef\[email protected]=5
    \countdef\[email protected]=6
    \countdef\[email protected]=7
    \countdef\[email protected]=8
    \countdef\[email protected]=9
    \countdef\[email protected]=10
    \[email protected]=\year \[email protected]=\month \[email protected]=\day
    %
    \[email protected]=\[email protected]
    \divide\[email protected] by 100%
    \multiply\[email protected] by 100%
    \[email protected]=\[email protected]
    \advance\[email protected] by -\[email protected]\relax
    %
    \ifodd\[email protected]
       \[email protected]
    \else
       \[email protected]=\[email protected]
       \divide\[email protected] by 2\relax
       \ifodd\[email protected]\[email protected]
       \else
          \ifnum\[email protected]=0%
             \[email protected]=\[email protected]
             \divide\[email protected] by 400\relax
             \multiply\[email protected] by 400\relax
             \ifnum\[email protected]=\[email protected]\[email protected]\else\[email protected]\fi
          \else\[email protected]
          \fi
       \fi
    \fi
    %
    \chardef\[email protected]\[email protected]\chardef\[email protected]\else\chardef\[email protected]\fi
    \chardef\[email protected]\chardef\[email protected]%
    \chardef\[email protected]\chardef\[email protected]%
    \chardef\[email protected]\chardef\[email protected]%
    \chardef\[email protected]\chardef\[email protected]%
    \chardef\[email protected]\chardef\[email protected]%
    %
    \[email protected]=\[email protected]
    \advance\[email protected] by -17\relax
    \[email protected]=\[email protected]
    \divide\[email protected] by 33\relax
    \multiply\[email protected] by 33\relax
    \advance\[email protected] by -\[email protected]
    \ifnum\[email protected]=32\relax\[email protected]
    \else
       \[email protected]=\[email protected]
       \divide\[email protected] by 4\relax
       \multiply\[email protected] by 4\relax
       \advance\[email protected] by -\[email protected]
       \ifnum\[email protected]=\[email protected]\[email protected]\else\[email protected]\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.
    %
    \[email protected]=\[email protected]                 % Number of Leap years
    \advance\[email protected] by\[email protected]
    \[email protected]=\[email protected]              % T := (MY-1) div 4
    \divide\[email protected] by 4\relax
    \[email protected]=\[email protected]           % T := T - ((MY-1) div 100)
    \divide\[email protected] by 100\relax
    \advance\[email protected] by -\[email protected]
    \[email protected]=\[email protected]           % T := T + ((MY-1) div 400)
    \divide\[email protected] by 400\relax
    \advance\[email protected] by \[email protected]
    \advance\[email protected] by -611       % Number of Kabise years
    \[email protected]=\[email protected]           % T := T - ((SY+10) div 33) * 8
    \divide\[email protected] by 33\relax
    \multiply\[email protected] by 8\relax
    \advance\[email protected] by -\[email protected]
    \[email protected]=\[email protected]           %
    \divide\[email protected] by 33\relax
    \multiply\[email protected] by 33\relax
    \advance\[email protected] by -\[email protected]
    \ifnum\[email protected]=32\advance\[email protected] by\@ne\fi % if (SY+10) mod 33=32 then Inc(T);
    \divide\[email protected] by 4\relax     % T := T - ((SY+10) mod 33) div 4
    \advance\[email protected] by -\[email protected]
    \advance\[email protected] by -137            % T := T - 137  Adjust the value
    \[email protected]=31
    \advance\[email protected] by-\[email protected]     % now 31 - T is the farsii
    \chardef\[email protected]\[email protected]
    \chardef\[email protected]
    \[email protected]\chardef\[email protected]\else\chardef\[email protected]\fi
    \chardef\[email protected]\chardef\[email protected]%
    \chardef\[email protected]\chardef\[email protected]%
    \chardef\[email protected]\chardef\[email protected]%
    \chardef\[email protected]\chardef\[email protected]%
    \chardef\[email protected]\chardef\[email protected]%
    %
    \[email protected]=0\relax
    \[email protected]=0\relax
    \[email protected]=\[email protected]
    \advance\[email protected] by\[email protected]\relax
    %
    \[email protected]=0\relax
    \ifnum\[email protected]<\[email protected]
      \loop
      \advance \[email protected] by\@ne\relax
      \advance\[email protected] by \csname [email protected]\romannumeral\[email protected]\endcsname
      \ifnum\[email protected]<\[email protected]\repeat
    \fi
    \advance \[email protected] by\[email protected]
    %
    \[email protected]=1\relax
    \[email protected]=\[email protected]
    \ifnum\[email protected]<\[email protected]
      \loop
      \advance\[email protected] by1\relax
      \advance\[email protected] by\csname [email protected]\romannumeral\[email protected]\endcsname
      \ifnum\[email protected]<\[email protected]\repeat
    \fi
    \ifnum\[email protected]<4%
       \[email protected]=9\advance\[email protected] by\[email protected]
       \advance\[email protected] by-622\relax
    \else
       \[email protected]=\[email protected] \advance\[email protected] by-3\relax
       \advance\[email protected] by-621\relax
    \fi
    \advance\[email protected] by -\csname [email protected]\romannumeral\[email protected]%
    \endcsname
    \ifnum\[email protected] =\@ne
      \[email protected]=\[email protected] \advance\[email protected] by30 \advance\[email protected] by-\[email protected]
    \else
      \[email protected]=\[email protected] \advance\[email protected] by-\[email protected]
    \fi
    %
    \xdef\[email protected]@d{\the\[email protected]}%
    \xdef\[email protected]@m{\the\[email protected]}%
    \xdef\[email protected]@y{\the\[email protected]}%
    }%
    \let\[email protected]\[email protected]@d
    \let\[email protected]\[email protected]@m
    \let\[email protected]\[email protected]@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 
     
  3. mba2431

    mba2431 Registered User

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

    mba2431 Registered User

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