How to Use Ruby Date Constants Gregorian, Julian, England and Even Italy

How do I use ruby Date constants GREGORIAN, JULIAN, ENGLAND and even ITALY

All the constants are explained in the documentation. As a rule of thumb, if the below explanations don't mean anything to you, you probably don't need to worry about those constants at all.

ENGLAND The Julian day number of the day of calendar reform for
England and her colonies.

GREGORIAN The Julian day number of the day of calendar reform for the
proleptic Gregorian calendar

ITALY The Julian day number of the day of calendar reform for Italy
and some catholic countries.

JULIAN The Julian day number of the day of calendar reform for the
proleptic Julian calendar

Here's more info on the different calendar systems:

  • http://en.wikipedia.org/wiki/Julian_calendar
  • http://en.wikipedia.org/wiki/Gregorian_calendar

How do I use ruby Date constants GREGORIAN, JULIAN, ENGLAND and even ITALY

All the constants are explained in the documentation. As a rule of thumb, if the below explanations don't mean anything to you, you probably don't need to worry about those constants at all.

ENGLAND The Julian day number of the day of calendar reform for
England and her colonies.

GREGORIAN The Julian day number of the day of calendar reform for the
proleptic Gregorian calendar

ITALY The Julian day number of the day of calendar reform for Italy
and some catholic countries.

JULIAN The Julian day number of the day of calendar reform for the
proleptic Julian calendar

Here's more info on the different calendar systems:

  • http://en.wikipedia.org/wiki/Julian_calendar
  • http://en.wikipedia.org/wiki/Gregorian_calendar

Effect of leaving space after '-' in Ruby expression

What actually happens is this:

Date.today(-29.days) # => Fri, 07 Feb 2014

today has an optional parameter called start, which defaults to Date::ITALY.

An optional argument the day of calendar reform (start) as a Julian
day number, which should be 2298874 to 2426355 or -/+oo. The default
value is Date::ITALY (2299161=1582-10-15).

Passing -29.days to today apparently has no effect.

Whereas:

Date.today + -29.days # => Thu, 09 Jan 2014

Which is the same as:

Date.today - 29.days # => Thu, 09 Jan 2014

DateTime and Julian Calendar - What's wrong with DateTime.ToString()?

Using an extension method:

static class JulianPrinter
{
public static string ToString(this DateTime date, string format, CultureInfo ci, Calendar cal)
{
if (format == "D")
return string.Format("{0}, {1} {2} {3}",
ci.DateTimeFormat.GetDayName(cal.GetDayOfWeek(date)),
cal.GetDayOfMonth(date),
ci.DateTimeFormat.MonthGenitiveNames[cal.GetMonth(date) - 1], //ci.DateTimeFormat.GetMonthName(cal.GetMonth(date)),
cal.GetYear(date));
return "";
}
}

...and :

var calend = new JulianCalendar();
DateTime dt = new DateTime(year, j, i, calend);
string printed = dt.ToString("D", ci, calend);

Is it possible to format/convert date for 13 month calendar (Georgian Calendar )

Divide the total seconds of the year and provide any property name for the given period.

Explain some parameters of IntlDateFormatter's constructor

Those flags specify how much information to output about the date/time. The documentation about the constants used give a little more insight than what you linked in your question.

So basically if datetype is set to IntlDateFormatter::LONG the output should be January 12, 1952, or if it was set to IntlDateFormatter::MEDIUM than the output should be Jan 12, 1952.



Related Topics



Leave a reply



Submit