Top Description Fields Constructors Methods
org.jruby.ext.date

public Class RubyDateTime

extends RubyDate
Class Inheritance
Annotations
@JRubyClass
name:DateTime
Imports
org.jcodings.specific.USASCIIEncoding, org.joda.time.Chronology, .DateTime, .DateTimeZone, org.joda.time.chrono.GJChronology, org.jruby.Ruby, .RubyArray, .RubyBignum, .RubyClass, .RubyFixnum, .RubyFloat, .RubyInteger, .RubyNumeric, .RubyRational, .RubyString, .RubyTime, org.jruby.anno.JRubyClass, .JRubyMethod, org.jruby.runtime.Arity, .ThreadContext, org.jruby.runtime.builtin.IRubyObject, org.jruby.util.ByteList, java.io.Serializable, java.math.BigDecimal, .BigInteger, .RoundingMode, java.time.*

JRuby's DateTime implementation - 'native' parts. In MRI, since 2.x, all of date.rb has been moved to native (C) code.

Note

There's still date.rb, where this gets bootstrapped from.

Author
kares
Since
9.2
See Also
RubyDate

Field Summary

Modifier and TypeField and Description
private static final String
private static final ByteList
private static final ByteList
Inherited from org.jruby.ext.date.RubyDate:
CHRONO_ITALY_UTCDAY_IN_SECONDSDAY_MSdefaultDateTimedtENGLANDGREGORIANITALYJULIANLOGoffREFORM_BEGIN_YEARREFORM_END_YEARstartSUB_MS_PRECISIONsubMillisDensubMillisNum

Constructor Summary

AccessConstructor and Description
protected
RubyDateTime(Ruby runtime, RubyClass klass)

public
RubyDateTime(Ruby runtime, RubyClass klass, DateTime dt)

public
RubyDateTime(Ruby runtime, DateTime dt)
Deprecated since 10.0.

public
RubyDateTime(Ruby runtime, long millis, Chronology chronology)

pack-priv
RubyDateTime(ThreadContext context, RubyClass klass, IRubyObject ajd, int off, long start)

private
RubyDateTime(ThreadContext context, RubyClass klass, IRubyObject ajd, long[] rest, int off, long start)

private
RubyDateTime(Ruby runtime, RubyClass klass, DateTime dt, int off)

pack-priv
RubyDateTime(Ruby runtime, RubyClass klass, DateTime dt, int off, long start)

pack-priv
RubyDateTime(Ruby runtime, RubyClass klass, DateTime dt, int off, long start, long subMillisNum, long subMillisDen)

pack-priv
RubyDateTime(ThreadContext context, RubyClass klass, IRubyObject ajd, Chronology chronology, int off)

Method Summary

Modifier and TypeMethod and Description
public static IRubyObject
public static IRubyObject
private static void
addFraction(ThreadContext context, final long[] rest, RubyNumeric fr, boolean roundFloat)

private static void
addRationalModToRest(ThreadContext context, IRubyObject val, long ival, final long[] rest)

private static void
addRationalModToRest(ThreadContext context, RubyRational rat, long ival, final long[] rest)

private static void
private static void
calcBigIntDayRest(ThreadContext context, final RubyRational day, final long d, final long[] rest)

public static RubyDateTime
civil(ThreadContext context, IRubyObject self)

Hides org.jruby.ext.date.RubyDate.civil.

# Create a new DateTime object corresponding to the specified # Civil Date and hour +h+, minute +min+, second +s+.

public static RubyDateTime
public static RubyDateTime
public static RubyDateTime
pack-priv static void
pack-priv static long
getDay(ThreadContext context, IRubyObject day, final long[] rest)

pack-priv static int
getHour(ThreadContext context, IRubyObject hour, final long[] rest)

pack-priv static int
getMinute(ThreadContext context, IRubyObject val, final long[] rest)

pack-priv static int
getSecond(ThreadContext context, IRubyObject val, final long[] rest)

private static boolean
public static RubyDateTime
jd(ThreadContext context, IRubyObject self)

Hides org.jruby.ext.date.RubyDate.jd.

# Create a new DateTime object corresponding to the specified # Julian Day Number +jd+ and hour +h+, minute +min+, second +s+.

public static RubyDateTime
jd(ThreadContext context, IRubyObject self, IRubyObject[] args)

pack-priv RubyDate
newInstance(final ThreadContext context, final DateTime dt, int off, long start, long subNum, long subDen)

Overrides org.jruby.ext.date.RubyDate.newInstance.

public IRubyObject
public static RubyDateTime
now(ThreadContext context, IRubyObject self)

# Create a new DateTime object representing the current time.

public static RubyDateTime
public IRubyObject
private RubyDate
prevNextDay(ThreadContext context, IRubyObject n, final boolean negate)

public RubyString
public RubyString
public RubyDate
public RubyDateTime
public RubyString
public RubyTime
public <T> T
toJava(Class<T>
The target type to which the object should be converted.
target
)

Overrides org.jruby.ext.date.RubyDate.toJava.

Implements org.jruby.runtime.builtin.IRubyObject.toJava.

Convert the object to the specified Java class, if possible.

public LocalDateTime

Returns:

a date time
toLocalDateTime
()

public OffsetDateTime

Returns:

a date time
toOffsetDateTime
()

public ZonedDateTime

Returns:

a date time
toZonedDateTime
()

pack-priv static DateTime
Inherited from org.jruby.ext.date.RubyDate:
_comp_year69_i_load_match_parse_day_parse_ddd_parse_dot_parse_eu_parse_impl_parse_iso_parse_iso2_parse_jis_parse_mday_parse_mon_parse_sla_parse_time_parse_us_parse_vms_parse_year_s3e_strptime_subs_valid_civil_p_valid_civil_p_valid_commercial_p_valid_jd_p_valid_jd_p_valid_ordinal_p_valid_ordinal_p_valid_time_p_valid_weeknum_padjustJodaYearajdamjdcivilcivilDatecivilImplcivilImplcommercialcreateDateClasscwdaycweekcwyearday_fractiondebugenglandeql_pequalsequalsformatgetChronologygetChronologygetDategetDategetDateTimegetDateTimegetDateTimegetDaygetHourgetJavaClassgetJulianDayNumbergetMinutegetMonthgetMonthgetMonthgetNanosgetSecondgetValidStartgetYeargetYeargetYeargregoriangregorian_leap_pgregorian_phashhashCodehourinitializeinitializeinitializeinitialize_copyinspectisDateTimeisDateTimeisJulianitalyjdjdjdjd_to_ajdjd_to_ajdjd_to_ajdjd_to_ajdjulianjulian_leap_pjulian_pldleap_pmarshal_dumpmarshal_loadmdayminutemjdmonnew_new_new_new_new_offsetnew_startnew_startnewDateErrornewInstancenewRationalConvertnextnext_daynext_monthnext_monthnext_yearnext_yearnormalizeSubMillisoffsetop_cmpop_eqqop_minusop_plusop_plus_numericordinalparseparse_bcparse_fragprev_dayprev_monthprev_monthprev_yearprev_yearroundToPrecisionsec_fractionsecondshift_bwshift_fwstartsubMillistimesIntDifftimeToDayFractionto_dateto_datetimetoDatetodaytodaytoInstanttoLocalDateval2offval2sgvalid_civil_pvalid_commercial_pvalid_jd_pvalid_jd_pvalid_ordinal_pvalid_sgvalidCivilImplvalidCommercialImplvalidOrdinalImplwdayydayyearzonezone_to_diff

Field Detail

DEFAULT_FORMATback to summary
private static final String DEFAULT_FORMAT

Hides org.jruby.ext.date.RubyDate.DEFAULT_FORMAT.

STRF_FORMAT_BYTESback to summary
private static final ByteList STRF_FORMAT_BYTES
TO_S_FORMATback to summary
private static final ByteList TO_S_FORMAT

Hides org.jruby.ext.date.RubyDate.TO_S_FORMAT.

Constructor Detail

RubyDateTimeback to summary
protected RubyDateTime(Ruby runtime, RubyClass klass)
RubyDateTimeback to summary
public RubyDateTime(Ruby runtime, RubyClass klass, DateTime dt)
RubyDateTimeback to summary
public RubyDateTime(Ruby runtime, DateTime dt)

Deprecated

since 10.0.

Annotations
@Deprecated
since:10.0
RubyDateTimeback to summary
public RubyDateTime(Ruby runtime, long millis, Chronology chronology)
RubyDateTimeback to summary
pack-priv RubyDateTime(ThreadContext context, RubyClass klass, IRubyObject ajd, int off, long start)
RubyDateTimeback to summary
private RubyDateTime(ThreadContext context, RubyClass klass, IRubyObject ajd, long[] rest, int off, long start)
RubyDateTimeback to summary
private RubyDateTime(Ruby runtime, RubyClass klass, DateTime dt, int off)
RubyDateTimeback to summary
pack-priv RubyDateTime(Ruby runtime, RubyClass klass, DateTime dt, int off, long start)
RubyDateTimeback to summary
pack-priv RubyDateTime(Ruby runtime, RubyClass klass, DateTime dt, int off, long start, long subMillisNum, long subMillisDen)
RubyDateTimeback to summary
pack-priv RubyDateTime(ThreadContext context, RubyClass klass, IRubyObject ajd, Chronology chronology, int off)

Method Detail

_strptimeback to summary
public static IRubyObject _strptime(ThreadContext context, IRubyObject self, IRubyObject string)

Hides org.jruby.ext.date.RubyDate._strptime.

Annotations
@JRubyMethod
meta:true
_strptimeback to summary
public static IRubyObject _strptime(ThreadContext context, IRubyObject self, IRubyObject string, IRubyObject format)

Hides org.jruby.ext.date.RubyDate._strptime.

Annotations
@JRubyMethod
meta:true
addFractionback to summary
private static void addFraction(ThreadContext context, final long[] rest, RubyNumeric fr, boolean roundFloat)
addRationalModToRestback to summary
private static void addRationalModToRest(ThreadContext context, IRubyObject val, long ival, final long[] rest)
addRationalModToRestback to summary
private static void addRationalModToRest(ThreadContext context, RubyRational rat, long ival, final long[] rest)
assertValidFractionback to summary
private static void assertValidFraction(ThreadContext context, IRubyObject val, long ival)
calcBigIntDayRestback to summary
private static void calcBigIntDayRest(ThreadContext context, final RubyRational day, final long d, final long[] rest)
civilback to summary
public static RubyDateTime civil(ThreadContext context, IRubyObject self)

Hides org.jruby.ext.date.RubyDate.civil.

# Create a new DateTime object corresponding to the specified # Civil Date and hour +h+, minute +min+, second +s+. # # The 24-hour clock is used. Negative values of +h+, +min+, and # +sec+ are treating as counting backwards from the end of the # next larger unit (e.g. a +min+ of -2 is treated as 58). No # wraparound is performed. If an invalid time portion is specified, # an ArgumentError is raised. # # +of+ is the offset from UTC as a fraction of a day (defaults to 0). # +sg+ specifies the Day of Calendar Reform. # # +y+ defaults to -4712, +m+ to 1, and +d+ to 1; this is Julian Day # Number day 0. The time values default to 0.

Annotations
@JRubyMethod
name:civil
alias:new
meta:true
civilback to summary
public static RubyDateTime civil(ThreadContext context, IRubyObject self, IRubyObject year)

Hides org.jruby.ext.date.RubyDate.civil.

Annotations
@JRubyMethod
name:civil
alias:new
meta:true
civilback to summary
public static RubyDateTime civil(ThreadContext context, IRubyObject self, IRubyObject year, IRubyObject month)

Hides org.jruby.ext.date.RubyDate.civil.

Annotations
@JRubyMethod
name:civil
alias:new
meta:true
civilback to summary
public static RubyDateTime civil(ThreadContext context, IRubyObject self, IRubyObject[] args)

Hides org.jruby.ext.date.RubyDate.civil.

Annotations
@JRubyMethod
name:civil
alias:new
meta:true
optional:8
checkArity:false
createDateTimeClassback to summary
pack-priv static void createDateTimeClass(ThreadContext context, RubyClass Date)
getDayback to summary
pack-priv static long getDay(ThreadContext context, IRubyObject day, final long[] rest)
getHourback to summary
pack-priv static int getHour(ThreadContext context, IRubyObject hour, final long[] rest)
getMinuteback to summary
pack-priv static int getMinute(ThreadContext context, IRubyObject val, final long[] rest)
getSecondback to summary
pack-priv static int getSecond(ThreadContext context, IRubyObject val, final long[] rest)
isSecondAWholeNumberback to summary
private static boolean isSecondAWholeNumber(ThreadContext context, IRubyObject val)
jdback to summary
public static RubyDateTime jd(ThreadContext context, IRubyObject self)

Hides org.jruby.ext.date.RubyDate.jd.

# Create a new DateTime object corresponding to the specified # Julian Day Number +jd+ and hour +h+, minute +min+, second +s+. # # The 24-hour clock is used. Negative values of +h+, +min+, and # +sec+ are treating as counting backwards from the end of the # next larger unit (e.g. a +min+ of -2 is treated as 58). No # wraparound is performed. If an invalid time portion is specified, # an ArgumentError is raised. # # +of+ is the offset from UTC as a fraction of a day (defaults to 0). # +sg+ specifies the Day of Calendar Reform. # # All day/time values default to 0.

Annotations
@JRubyMethod
name:jd
meta:true
jdback to summary
public static RubyDateTime jd(ThreadContext context, IRubyObject self, IRubyObject[] args)
Annotations
@JRubyMethod
name:jd
meta:true
optional:6
checkArity:false
newInstanceback to summary
pack-priv RubyDate newInstance(final ThreadContext context, final DateTime dt, int off, long start, long subNum, long subDen)

Overrides org.jruby.ext.date.RubyDate.newInstance.

Annotations
@Override
next_dayback to summary
public IRubyObject next_day(ThreadContext context, IRubyObject n)

Overrides org.jruby.ext.date.RubyDate.next_day.

Annotations
@Override
nowback to summary
public static RubyDateTime now(ThreadContext context, IRubyObject self)

# Create a new DateTime object representing the current time. # # +sg+ specifies the Day of Calendar Reform.

Annotations
@JRubyMethod
meta:true
nowback to summary
public static RubyDateTime now(ThreadContext context, IRubyObject self, IRubyObject sg)
Annotations
@JRubyMethod
meta:true
prev_dayback to summary
public IRubyObject prev_day(ThreadContext context, IRubyObject n)

Overrides org.jruby.ext.date.RubyDate.prev_day.

Annotations
@Override
prevNextDayback to summary
private RubyDate prevNextDay(ThreadContext context, IRubyObject n, final boolean negate)
strftimeback to summary
public RubyString strftime(ThreadContext context)

Overrides org.jruby.ext.date.RubyDate.strftime.

Annotations
@JRubyMethod
strftimeback to summary
public RubyString strftime(ThreadContext context, IRubyObject fmt)

Overrides org.jruby.ext.date.RubyDate.strftime.

Annotations
@JRubyMethod
to_dateback to summary
public RubyDate to_date(ThreadContext context)
Annotations
@JRubyMethod
to_datetimeback to summary
public RubyDateTime to_datetime()
Annotations
@JRubyMethod
to_sback to summary
public RubyString to_s(ThreadContext context)

Overrides org.jruby.ext.date.RubyDate.to_s.

Annotations
@JRubyMethod
to_timeback to summary
public RubyTime to_time(ThreadContext context)

Overrides org.jruby.ext.date.RubyDate.to_time.

Annotations
@JRubyMethod
toJavaback to summary
public <T> T toJava(Class<T> target)

Overrides org.jruby.ext.date.RubyDate.toJava.

Implements org.jruby.runtime.builtin.IRubyObject.toJava.

Doc from org.jruby.runtime.builtin.IRubyObject.toJava.

Convert the object to the specified Java class, if possible.

Parameters
<T>
type
target:Class<T>

The target type to which the object should be converted.

Returns:T

java type

Annotations
@Override
toLocalDateTimeback to summary
public LocalDateTime toLocalDateTime()
Returns:LocalDateTime

a date time

toOffsetDateTimeback to summary
public OffsetDateTime toOffsetDateTime()
Returns:OffsetDateTime

a date time

toZonedDateTimeback to summary
public ZonedDateTime toZonedDateTime()
Returns:ZonedDateTime

a date time

withTimeAt0InZoneback to summary
pack-priv static DateTime withTimeAt0InZone(DateTime dt, DateTimeZone zone)