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

public Class RubyDate

extends RubyObject
Class Inheritance
Known Direct Subclasses
org.jruby.ext.date.RubyDateTime
Annotations
@JRubyClass
name:Date
Imports
org.jcodings.specific.USASCIIEncoding, org.joda.time.DateTime, .DateTimeUtils, .DateTimeZone, .Chronology, .Instant, org.joda.time.chrono.GJChronology, .GregorianChronology, .JulianChronology, org.joni.Regex, org.jruby.*, org.jruby.anno.JRubyClass, .JRubyMethod, org.jruby.exceptions.RaiseException, org.jruby.java.proxies.JavaProxy, org.jruby.javasupport.JavaUtil, org.jruby.runtime.*, org.jruby.runtime.builtin.IRubyObject, org.jruby.util.*, org.jruby.util.log.Logger, .LoggerFactory, java.io.Serializable, java.time.*, java.util.Calendar, .Date, .GregorianCalendar

JRuby's Date 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.

Authors
enebo, kares
Since
9.2

Field Summary

Modifier and TypeField and Description
private static final ByteList
private static final ByteList
private static final ByteList
private static final ByteList
private static final ByteList
private static final ByteList
private static final ByteList
private static final ByteList
private static final ByteList
private static final ByteList
private static final ByteList
private static final ByteList
private static final ByteList
private static final ByteList
private static final ByteList[]
private static final ByteList[]
pack-priv static final GJChronology
pack-priv static final int
pack-priv static final int
private RubyFixnum
private static final String
private static final ByteList
pack-priv static final DateTime
pack-priv DateTime
pack-priv static final int
pack-priv static final long
private static final double
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
pack-priv static final int
pack-priv static final long
private static final double
private static final int
pack-priv static final Logger
private static final int
private static final int
pack-priv int
private static final int
pack-priv static final int
private static final int
pack-priv static final int
private static final ByteList
pack-priv long
pack-priv static final int
pack-priv long
pack-priv long
private static final ByteList
private static final ByteList
Inherited from org.jruby.RubyObject:
IVAR_INSPECTING_OBJECT_ALLOCATOROBJECT_ALLOCATORREIFYING_OBJECT_ALLOCATOR

Constructor Summary

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

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

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

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

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

public
RubyDate(Ruby runtime, long millis, Chronology chronology)
Deprecated since 10.0.

public
RubyDate(ThreadContext context, long millis, Chronology chronology)

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

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

pack-priv
RubyDate(ThreadContext context, RubyClass klass, IRubyObject ajd, long[] rest, int off, long start)

private
RubyDate(ThreadContext context, RubyClass klass, IRubyObject ajd, Chronology chronology, int off, long start)

Method Summary

Modifier and TypeMethod and Description
public static RubyInteger
public static RubyInteger
public static RubyDate
public static IRubyObject
pack-priv static IRubyObject
public static IRubyObject
pack-priv static IRubyObject
pack-priv static IRubyObject
public static IRubyObject
pack-priv static IRubyObject
public static IRubyObject
public static IRubyObject
pack-priv static IRubyObject
pack-priv static IRubyObject
pack-priv static IRubyObject
pack-priv static IRubyObject
pack-priv static IRubyObject
public static IRubyObject
pack-priv static IRubyObject
public static IRubyObject
_s3e(ThreadContext context, IRubyObject self, IRubyObject[] args)

public static IRubyObject
public static IRubyObject
public static IRubyObject
public static IRubyObject
public static IRubyObject
public IRubyObject
_valid_civil_p(ThreadContext context, IRubyObject[] args)
Deprecated

public static IRubyObject
_valid_commercial_p(ThreadContext context, IRubyObject self, IRubyObject[] args)
Deprecated

public static IRubyObject
public static IRubyObject
public static IRubyObject
_valid_ordinal_p(ThreadContext context, IRubyObject self, IRubyObject[] args)
Deprecated

public IRubyObject
_valid_ordinal_p(ThreadContext context, IRubyObject[] args)
Deprecated

public static IRubyObject
public static IRubyObject
_valid_weeknum_p(ThreadContext context, IRubyObject self, IRubyObject[] args)
Deprecated

pack-priv final int
adjustJodaYear(int year)

private void
adjustWithDayFraction(ThreadContext context, DateTime dt, final long[] rest)

public IRubyObject
ajd(ThreadContext context)

public IRubyObject
private static void
append(final ByteList out, String val)

private static int
public static RubyDate
civil(ThreadContext context, IRubyObject self)

# Create a new Date object for the Civil Date specified by # year +y+, month +m+, and day-of-month +d+.

public static RubyDate
public static RubyDate
public static RubyDate
public static RubyDate
civil(ThreadContext context, IRubyObject self, IRubyObject[] args)

public static DateTime
civilDate(ThreadContext context, final int y, final int m, final int d, final Chronology chronology)

pack-priv static DateTime
pack-priv static DateTime
private static RubyDate
civilImpl(ThreadContext context, RubyClass klass, IRubyObject year, IRubyObject month, IRubyObject mday, final long sg)

private int
cmp(ThreadContext context, final RubyDate that)

private int
cmpSubMillis(ThreadContext context, final RubyDate that)

public static RubyDate
pack-priv static RubyClass
private static RubyInteger
cstr2num(Ruby runtime, RubyString str, int bp, int ep)

public RubyInteger
public RubyInteger
public RubyInteger
public RubyNumeric
private RubyFixnum
DAY_MS(final ThreadContext context)

private static int
pack-priv static void
debug(ThreadContext context, final String msg, Exception ex)

private static void
do_parse(ThreadContext context, IRubyObject self, RubyString str, RubyHash hash, final int flags)

public IRubyObject
public IRubyObject
public boolean
equals(Object
object to compare
other
)

Overrides org.jruby.RubyObject.equals.

This override does not do a "checked" dispatch.

public final boolean
private IRubyObject
private IRubyObject
pack-priv static RubyString
format(ThreadContext context, ByteList fmt, IRubyObject... args)

public static Chronology
getChronology(ThreadContext context, final long sg, final int off)

pack-priv static Chronology
getChronology(ThreadContext context, final long sg, final DateTimeZone zone)

pack-priv static RubyClass
getDate(final Ruby runtime)
Deprecated since 10.0.

pack-priv static RubyClass
pack-priv static RubyClass
getDateTime(final Ruby runtime)
Deprecated since 10.0.

pack-priv static RubyClass
public DateTime
public int

Returns:

day-of-month
getDay
()

public int

Returns:

hour-of-day (0..23)
getHour
()

public Class<T>
getJavaClass()

Overrides org.jruby.RubyBasicObject.getJavaClass.

Implements org.jruby.runtime.builtin.IRubyObject.getJavaClass.

Will return the Java interface that most closely can represent this object, when working through Java integration translations.

public final long
public int

Returns:

minute-of-hour
getMinute
()

pack-priv static int
getMonth(IRubyObject month)
Deprecated since 10.0.

pack-priv static int
public int

Returns:

month-of-year (1..12)
getMonth
()

public int

Returns:

the nano second part (only) of time
getNanos
()

public int

Returns:

second-of-minute
getSecond
()

pack-priv static long
getValidStart(final ThreadContext context, final double sg, final int DEFAULT_SG)

pack-priv static int
getYear(IRubyObject year)
Deprecated since 10.0.

pack-priv static int
public int

Returns:

year
getYear
()

public IRubyObject
public static IRubyObject
public RubyBoolean
public RubyFixnum
hash(ThreadContext
the current thread context
context
)

Overrides org.jruby.RubyBasicObject.hash.

Will return the hash code of this object.

public int
hashCode()

Overrides org.jruby.RubyObject.hashCode.

This override does not do "checked" dispatch since Object usually has #hash defined.

private static IRubyObject
hashGet(final ThreadContext context, final RubyHash hash, final String key)

private static boolean
hashGetTest(final ThreadContext context, final RubyHash hash, final String key)

public RubyInteger
public RubyDate
initialize(ThreadContext context, IRubyObject dt)
Deprecated since 9.4-. kept due AR-JDBC (uses RubyClass.newInstance(...) to 'fast' allocate a Date instance)

Note

since Date.new is a civil alias, this won't ever get used

public RubyDate
public RubyDate
private void
initialize(final ThreadContext context, IRubyObject arg, IRubyObject of, final long start)

public IRubyObject
initialize_copy(ThreadContext
the thread context
context
,
IRubyObject
the original
original
)

Overrides org.jruby.RubyBasicObject.initialize_copy.

Initializes this object as a copy of the original, that is the parameter to this object.

private long
initMillis(final ThreadContext context, IRubyObject ajd)

public RubyString
inspect(ThreadContext context)

Overrides org.jruby.RubyBasicObject.inspect.

Overrides default org.jruby.runtime.builtin.IRubyObject.inspect.

Returns a string containing a human-readable representation of obj.

private static boolean
isAlpha(char c)

pack-priv static boolean
isDateTime(final Ruby runtime, final IRubyObject type)
Deprecated since 10.0.

pack-priv static boolean
isDateTime(ThreadContext context, final IRubyObject type)

private static boolean
isDigit(char c)

private static boolean
isGregorianLeap(final long year)

public final boolean
private static boolean
isJulianLeap(final long year)

public IRubyObject
public static RubyDate
jd(ThreadContext context, IRubyObject self)

Create a new Date object from a Julian Day Number.

public static RubyDate
public static RubyDate
public RubyFixnum
jd(ThreadContext context)

private static double
jd_to_ajd(long jd)

pack-priv static RubyNumeric
jd_to_ajd(ThreadContext context, long jd)

pack-priv static RubyNumeric
jd_to_ajd(ThreadContext context, long jd, RubyNumeric fr, int of_sec)

pack-priv static RubyNumeric
jd_to_ajd(ThreadContext context, RubyNumeric jd, RubyNumeric fr, int of_sec)

public static RubyNumeric
private static RubyDate
jdImpl(ThreadContext context, IRubyObject self, IRubyObject jd, final long sg)

public IRubyObject
public static IRubyObject
public RubyBoolean
public IRubyObject
ld(ThreadContext context)

public IRubyObject
public IRubyObject
public RubyDate
private IRubyObject
private static RubyString
matchOrNull(ThreadContext context, final RubyMatchData match, int i)

public RubyInteger
public RubyInteger
public IRubyObject
mjd(ThreadContext context)

public RubyInteger
mon(ThreadContext context)

private static int
public static RubyDate
new_(ThreadContext context, IRubyObject self)
Deprecated since 9.4-. internal Date.new!

public static RubyDate
new_(ThreadContext context, IRubyObject self, IRubyObject ajd)
Deprecated since 9.4-. internal Date.new!

public static RubyDate
new_(ThreadContext context, IRubyObject self, IRubyObject ajd, IRubyObject of)
Deprecated since 9.4-. internal Date.new!

public static RubyDate
new_(ThreadContext context, IRubyObject self, IRubyObject ajd, IRubyObject of, IRubyObject sg)
Deprecated since 9.4-. internal Date.new!

public IRubyObject
public IRubyObject
public IRubyObject
pack-priv static RaiseException
newDateError(ThreadContext context, String message)

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

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

pack-priv static RubyRational
private static RubyRegexp
newRegexpFromCache(ThreadContext context, ByteList str, int opts)

private RubyDate
newStart(ThreadContext context, final long start)

public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
pack-priv final RubyDate
private static long
normIntValue(ThreadContext context, IRubyObject val, final int negOffset)

private static ByteList
of2str(final int of)

public IRubyObject
public IRubyObject
public IRubyObject

Returns:

true/false/nil
op_eqq
(ThreadContext context, IRubyObject other)

Overrides org.jruby.RubyObject.op_eqq.

Implements org.jruby.runtime.builtin.IRubyObject.op_eqq.

The relationship operator for Date.

public IRubyObject
private RubyNumeric
op_minus_date(ThreadContext context, final RubyDate that)

public IRubyObject
pack-priv RubyDate
public static RubyDate
pack-priv static IRubyObject
parse(ThreadContext context, IRubyObject string, String format)

pack-priv static void
pack-priv static void
private static IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
private RubyDate
prevNextYear(ThreadContext context, IRubyObject n, final boolean negate)

pack-priv static RubyNumeric
roundToPrecision(ThreadContext context, RubyFloat sub, final long precision)

private static IRubyObject
s3e(ThreadContext context, final RubyHash hash, RubyString y, RubyString m, RubyString d, boolean bc)

public RubyNumeric
public RubyInteger
private static void
set_hash(final ThreadContext context, RubyHash hash, String key, IRubyObject val)

public IRubyObject
public IRubyObject
private static int
private static int
skipDigits(RubyString str, int off)

private static int
public IRubyObject
public RubyString
public RubyString
private static boolean
strPtr(RubyString str, char c)

pack-priv final RubyRational
subMillis(final ThreadContext context)

private RubyNumeric
subMillisDiff(final ThreadContext context, final RubyDate that)

private static IRubyObject
pack-priv static long
timesIntDiff(final ThreadContext context, IRubyObject n, final int times)

pack-priv static RubyNumeric
timeToDayFraction(ThreadContext context, int hour, int min, int sec)

public RubyDate
public RubyDateTime
public RubyString
public RubyTime
public Date
public static RubyDate
today(ThreadContext context, IRubyObject self)

# Create a new Date object representing today.

public static RubyDate
private static DateTime
todayDate(final ThreadContext context, final Chronology chrono)

public Instant

Returns:

an instant
toInstant
()

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

Overrides org.jruby.RubyBasicObject.toJava.

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

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

public LocalDate

Returns:

a (local) date
toLocalDate
()

pack-priv static int
pack-priv static long
public static IRubyObject
public static IRubyObject
public static IRubyObject
public static IRubyObject
public static IRubyObject
pack-priv static long
valid_sg(ThreadContext context, IRubyObject sg)
Deprecated since 10.0.

pack-priv static Long
validCivilImpl(ThreadContext context, IRubyObject year, IRubyObject month, IRubyObject day, final long sg)

pack-priv static Long
validCommercialImpl(ThreadContext context, IRubyObject year, IRubyObject week, IRubyObject day, final long sg)

private static boolean
pack-priv static Long
validOrdinalImpl(ThreadContext context, IRubyObject year, IRubyObject day, final long sg)

private static Long
validOrdinalImpl(ThreadContext context, IRubyObject year, int day, final long sg)

private static IRubyObject
public RubyInteger
public RubyInteger
public RubyInteger
public RubyString
public static IRubyObject
Inherited from org.jruby.RubyObject:
attachToObjectSpacecallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitconvertToTypedigdig1dig2eqlInternalequalInternalfinishObjectClassgetNativeClassIndexinspectputsspecificEvaltoRubyStringtoString