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, RootDir, 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

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

Methods included from Coordinates

to_deg, to_deg_225, to_dms

Methods included from When

Calendar, CalendarEra, CalendarNote, Clock, Duration, Location, M17n, MonthName, Pair, Residue, Resource, TemporalPosition, Wikipedia, _setup_, _setup_info, 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, _instantiate, _parse, _path_with_prefix, _replace_tags, _setup_, _setup_info, _simplify_path, base_uri, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #next, #parent, #prev, #registered?, root_dir

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:



1199
1200
1201
# File 'lib/when_exe/tmposition.rb', line 1199

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

._t_to_d(t) ⇒ Numeric

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

Parameters:

Returns:



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

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

Instance Method Details

#%(other) ⇒ Numeric

ユリウス日の剰余

Parameters:

Returns:

Raises:

  • (TypeError)


1237
1238
1239
1240
1241
# File 'lib/when_exe/tmposition.rb', line 1237

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)


1222
1223
1224
1225
1226
1227
1228
1229
# File 'lib/when_exe/tmposition.rb', line 1222

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

加算



1210
1211
1212
1213
1214
# File 'lib/when_exe/tmposition.rb', line 1210

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:



745
746
747
# File 'lib/when_exe/inspect.rb', line 745

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

#to_s(precision = @precision) ⇒ String

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

Parameters:

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

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

Returns:



755
756
757
758
# File 'lib/when_exe/inspect.rb', line 755

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