Class: When::TM::JulianDate

Inherits:
Coordinate show all
Defined in:
lib/when_exe/tmposition.rb,
lib/when_exe/inspect.rb

Overview

ユリウス日

see gml schema

Constant Summary collapse

JD19700101 =

Julian Day Number

19700101T120000Z
2440588
JD19700100_5 =
JD19700101 - 0.5

Constants inherited from TemporalPosition

TemporalPosition::AMPM, TemporalPosition::Format, TemporalPosition::HashProperty

Constants included from Coordinates

Coordinates::Bahai, Coordinates::CommonResidue, Coordinates::DefaultDateIndices, Coordinates::DefaultDayIndex, Coordinates::DefaultTimeIndices, Coordinates::IndianCities, Coordinates::Javanese, Coordinates::MATCH, Coordinates::Mayan, Coordinates::PERIOD, Coordinates::PERIOD_NAME, Coordinates::PRECISION, Coordinates::PRECISION_NAME, Coordinates::Tibetan, Coordinates::VALUE, Coordinates::Yi

Constants included from When

CENTURY, DAY, DECADE, DurationP1D, DurationP1M, DurationP1W, DurationP1Y, EUCJP, HOUR, MINUTE, MONTH, MinusInfinity, PlusInfinity, SECOND, STRING, SYSTEM, SourceURI, When::TimeValue, UTF8, VERSION, W31J, WEEK, YEAR

Constants included from Parts::Resource

Parts::Resource::LabelProperty

Constants included from IndeterminateValue

IndeterminateValue::After, IndeterminateValue::Before, IndeterminateValue::I, IndeterminateValue::Max, IndeterminateValue::Min, IndeterminateValue::Now, IndeterminateValue::S, IndeterminateValue::Unknown

Instance Attribute Summary

Attributes inherited from Coordinate

#universal_time

Attributes inherited from TemporalPosition

#events, #frame, #indeterminated_position, #location, #options, #precision, #query, #trans

Attributes included from Parts::Resource

#_pool, #child, #keys, #locale, #namespace

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Coordinate

#-, dynamical_time, new, universal_time

Methods inherited from TemporalPosition

#[email protected], #-, #<=>, #==, #[], #^, #_attr, _instance, #_notes, _options, _setup_, #_to_h, #_to_s, _verify, #calendar_name, #clock_name, #copy, #dynamical_time, #floor, #has_next?, #has_time?, #include?, #is?, #month_included, #note?, #notes, #period, #prev, #rate_of_clock, #reference_label, #scan, #strftime, #succ, #term, #time_standard, #to_clock_time, #to_date, #to_date_time, #to_date_uri, #to_f, #to_i, #to_residue, #to_time, #to_uri, #universal_time, #week_included, #year_included

Methods included from Coordinates

to_deg, to_dms

Methods included from When

Calendar, CalendarEra, CalendarNote, Clock, Duration, M17n, MonthName, Pair, Residue, Resource, TemporalPosition, _setup_, at, client, config, era, free_conv, m17n, now, server, today, utc, when?

Methods included from TemporalPosition::Conversion

#julian_date, #tm_position

Methods included from Parts::Resource

#[], #^, _decode, _encode, _extract_prefix, _instance, _parse, _path_with_prefix, _replace_tags, _setup_, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #next, #parent, #prev, #registered?

Methods included from Parts::Resource::Pool

#[], #[]=, #_pool, #_setup_, #pool_keys

Methods included from Parts::Resource::Synchronize

#synchronize

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class When::TM::TemporalPosition

Class Method Details

._d_to_t(d) ⇒ Numeric

ユリウス日をに日時の内部表現変換

Parameters:

Returns:


1189
1190
1191
# File 'lib/when_exe/tmposition.rb', line 1189

def _d_to_t(d)
  (d - JD19700100_5) * Duration::DAY
end

._t_to_d(t) ⇒ Numeric

日時の内部表現をユリウス日に変換

Parameters:

Returns:


1178
1179
1180
# File 'lib/when_exe/tmposition.rb', line 1178

def _t_to_d(t)
  t / Duration::DAY + JD19700100_5
end

Instance Method Details

#%(other) ⇒ Numeric

ユリウス日の剰余

Parameters:

Returns:

Raises:

  • (TypeError)

1227
1228
1229
1230
1231
# File 'lib/when_exe/tmposition.rb', line 1227

def %(other)
  raise TypeError,"The right operand should be When::Coordinates::Residue" unless other.kind_of?(Residue)
  raise ArgumentError,"The right operand should have a unit 'day'" unless other.event == 'day'
  other % to_i
end

#&(other) ⇒ When::TM::TemporalPosition

ユリウス日が指定の剰余となる日

Parameters:

Returns:

Raises:

  • (TypeError)

1212
1213
1214
1215
1216
1217
1218
1219
# File 'lib/when_exe/tmposition.rb', line 1212

def &(other)
  raise TypeError,"The right operand should be When::Coordinates::Residue" unless other.kind_of?(Residue)
  raise ArgumentError,"The right operand should have a unit 'day'" unless other.event == 'day'
  jdn      = to_i
  new_date = self.dup
  new_date.universal_time += ((other & jdn) - jdn) * Duration::DAY
  return new_date
end

#+(other) ⇒ When::TM::TemporalPosition

加算


1200
1201
1202
1203
1204
# File 'lib/when_exe/tmposition.rb', line 1200

def +(other)
  new_date = super
  new_date.frame = new_date.frame._daylight(new_date.universal_time) if new_date.frame && new_date.frame._need_validate
  return new_date
end

#to_m17n(precision = @precision) ⇒ When::BasicTypes::M17n

多言語対応文字列化 - ユリウス日を多言語対応文字列化する

Parameters:

  • precision (Integer) (defaults to: @precision)

    どの桁まで多言語対応文字列化するか、分解能で指定する

Returns:


731
732
733
# File 'lib/when_exe/inspect.rb', line 731

def to_m17n(precision=@precision)
  return m17n(to_s(precision))
end

#to_s(precision = @precision) ⇒ String

文字列化 - ユリウス日を文字列化する

Parameters:

  • precision (Integer) (defaults to: @precision)

    どの桁まで多言語対応文字列化するか、分解能で指定する

Returns:


741
742
743
744
# File 'lib/when_exe/inspect.rb', line 741

def to_s(precision=@precision)
  coordinate = (precision <= When::DAY) ? to_i : to_f
  coordinate.to_s
end