gregorian-calendar

How convert Gregorian date to Persian date?

本小妞迷上赌 提交于 2019-11-30 06:04:58
I want to convert a custom Gregorian date to Persian date in C#. For example, i have a string with this contents: string GregorianDate = "Thursday, October 24, 2013"; Now i want to have: string PersianDate = پنج‌شنبه 2 آبان 1392 ; or string PersianDate = 1392/08/02 Thanks Use the PersianCalendar: string GregorianDate = "Thursday, October 24, 2013"; DateTime d = DateTime.Parse(GregorianDate); PersianCalendar pc = new PersianCalendar(); Console.WriteLine(string.Format("{0}/{1}/{2}", pc.GetYear(d), pc.GetMonth(d), pc.GetDayOfMonth(d))); You can use PersianDateTime: PM> Install-Package

Converting a Gregorian date to Julian Day Count in Objective C

做~自己de王妃 提交于 2019-11-29 20:04:09
问题 I need Objective C method for converting Gregorian date to Julian days same as this PHP method (GregorianToJD). 回答1: According to http://en.wikipedia.org/wiki/Julian_day, the Julian day number for January 1, 2000, was 2,451,545. So you can compute the number of days between your date and this reference date. For example (Jan 1, 2014): NSUInteger julianDayFor01012000 = 2451545; NSCalendar *cal = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; [cal setTimeZone:[NSTimeZone

Java Gregorian Calendar Returns Wrong Month

柔情痞子 提交于 2019-11-29 18:00:34
So I been at this for a few hours now and it returns the correct Year, and Day but for some odd reason it returns the wrong month. I'm sure its a simple fix but I can't seem to figure it out. package gregoriancalendar; import java.util.GregorianCalendar; public class Calendar8_5 { public static void main(String[] args){ GregorianCalendar calendar = new GregorianCalendar(); System.out.println("Current Year, Month & Date: "); System.out.println("Year is " + calendar.get(1)); System.out.println("Month is " + calendar.get(2)); System.out.println("Day is " + calendar.get(5)); calendar

Convert between calendars

时光总嘲笑我的痴心妄想 提交于 2019-11-29 17:51:57
问题 How to convert between calendars? Here is what I have: UmAlQuraCalendar hijri = new UmAlQuraCalendar(); GregorianCalendar cal = new GregorianCalendar(); DateTime hijriDate = new DateTime(1434, 11, 23, hijri); DateTime gregorianDate = ...; // I need a gregorianDate that corresponds to the hijriDate . 回答1: It seems that the Date saved in DateTime is always in the current calendar. So if the current calendar is Gregorian hijriDate is already in Gregorian. var hijriDate = new DateTime(1434, 11,

Is .NET giving me the wrong week number for Dec. 29th 2008?

北城余情 提交于 2019-11-29 11:40:17
问题 According to the official (gregorian) calendar, the week number for 29/12/2008 is 1, because after the last day of week 52 (i.e. 28/12) there are three or less days left in the year. Kinda weird, but OK, rules are rules. So according to this calendar, we have these boundary values for 2008/2009 28/12 is week 52 29/12 is week 1 1/1 is week 1 8/1 is week 2 C# offers a GregorianCalendar class, that has a function GetWeekOfYear(date, rule, firstDayOfWeek) . The parameter rule is an enumeration

How to convert Gregorian string to Gregorian Calendar?

自闭症网瘾萝莉.ら 提交于 2019-11-29 11:40:01
I have to compute something based on the Calendar's date, but I am receiving the complete Gregorian Calendar's String value. Eg i/p received {may be - "new GregorianCalendar().toString()"} as String :- java.util.GregorianCalendar[time=1410521241348,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/London",offset=0,dstSavings=3600000,useDaylight=true,transitions=242,lastRule=java.util.SimpleTimeZone[id=Europe/London,offset=0,dstSavings=3600000,useDaylight=true,startYear=0,startMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000

How convert Gregorian date to Persian date?

安稳与你 提交于 2019-11-29 04:35:49
问题 I want to convert a custom Gregorian date to Persian date in C#. For example, i have a string with this contents: string GregorianDate = "Thursday, October 24, 2013"; Now i want to have: string PersianDate = پنج‌شنبه 2 آبان 1392 ; or string PersianDate = 1392/08/02 Thanks 回答1: Use the PersianCalendar: string GregorianDate = "Thursday, October 24, 2013"; DateTime d = DateTime.Parse(GregorianDate); PersianCalendar pc = new PersianCalendar(); Console.WriteLine(string.Format("{0}/{1}/{2}", pc

Displaying the last two digits of the current year in Java

◇◆丶佛笑我妖孽 提交于 2019-11-29 03:06:51
How can I display only the last two digits of the current year without using any substring algorithms or any third party libraries? I have tried the below method and it gave a four-digit year. I want to know whether there are any date formatting options available to get the current year in two-digit format. Calendar.getInstance().get(Calendar.YEAR); You can use a SimpleDateFormat to format a date as per your requirements. DateFormat df = new SimpleDateFormat("yy"); // Just the year, with 2 digits String formattedDate = df.format(Calendar.getInstance().getTime()); System.out.println

Converting Gregorian date to Hijri date

这一生的挚爱 提交于 2019-11-28 06:58:35
How do you convert Gregorian dates to Islamic Hijri dates using JavaScript? function gmod(n,m){ return ((n%m)+m)%m; } function kuwaiticalendar(adjust){ var today = new Date(); if(adjust) { adjustmili = 1000*60*60*24*adjust; todaymili = today.getTime()+adjustmili; today = new Date(todaymili); } day = today.getDate(); month = today.getMonth(); year = today.getFullYear(); m = month+1; y = year; if(m<3) { y -= 1; m += 12; } a = Math.floor(y/100.); b = 2-a+Math.floor(a/4.); if(y<1583) b = 0; if(y==1582) { if(m>10) b = -10; if(m==10) { b = 0; if(day>4) b = -10; } } jd = Math.floor(365.25*(y+4716))

How to convert Gregorian string to Gregorian Calendar?

余生长醉 提交于 2019-11-28 05:19:15
问题 I have to compute something based on the Calendar's date, but I am receiving the complete Gregorian Calendar's String value. Eg i/p received {may be - "new GregorianCalendar().toString()"} as String :- java.util.GregorianCalendar[time=1410521241348,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Europe/London",offset=0,dstSavings=3600000,useDaylight=true,transitions=242,lastRule=java.util.SimpleTimeZone[id=Europe/London,offset=0,dstSavings=3600000