Class: When::TM::JulianDate

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

Overview

ユリウス日

see CALENdeRsign

Constant Summary collapse

JD19700101 =

Julian Day Number

19700101T120000Z
2440588
JDN_of_MJD =

Modified Julian Date

see MJD

2400000.5
JDN_of_CEP =

Countdown to Equinoctial Planetconjunction

see CEP

2698162
JD19700100_5 =
JD19700101 - 0.5

Constants inherited from TemporalPosition

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

Constants included from Coordinates

Coordinates::Bahai, Coordinates::Chinese, Coordinates::Common, Coordinates::DefaultDateIndices, Coordinates::DefaultDayIndex, Coordinates::DefaultTimeIndices, Coordinates::Indian, Coordinates::Iranian, Coordinates::Javanese, Coordinates::LocationTable, Coordinates::MATCH, Coordinates::Mayan, Coordinates::PERIOD, Coordinates::PERIOD_NAME, Coordinates::PRECISION, Coordinates::PRECISION_NAME, Coordinates::Russian, Coordinates::Tibetan, Coordinates::VALUE, Coordinates::Yi

Constants included from When

AUTHOR, CENTURY, COPYRIGHT, DAY, DECADE, EUCJP, HOUR, MINUTE, MONTH, MinusInfinity, Month, P1D, P1M, P1W, P1Y, PT1H, PT1M, PT1S, PlusInfinity, RootDir, SECOND, STRING, SYSTEM, SourceURI, When::TimeValue, UTF8, VERSION, W31J, WEEK, Week, YEAR, YEARS

Constants included from Parts::Resource

Parts::Resource::ConstList, Parts::Resource::ConstTypes, Parts::Resource::IRIDecode, Parts::Resource::IRIDecodeTable, Parts::Resource::IRIEncode, Parts::Resource::IRIEncodeTable, Parts::Resource::IRIHeader, Parts::Resource::LabelProperty

Constants included from Namespace

Namespace::DC, Namespace::DCQ, Namespace::DCT, Namespace::FOAF, Namespace::OWL, Namespace::RDF, Namespace::RDFC, Namespace::RDFS, Namespace::RSS, Namespace::XSD

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, #local_time, new, #prev, #succ, universal_time

Methods inherited from TemporalPosition

#+@, #<=>, #==, #[], #^, #_attr, _instance, _instance_element, #_notes, _options, _setup_, _setup_info, _temporal_position, #_to_h, #_to_s, _verify, #apply_delayed_options, #calendar_name, #clock_name, #copy, #dynamical_time, #floor, format, #has_next?, #has_time?, #include?, #inspect, #is?, #month_included, #note?, #notes, #period, #rate_of_clock, #reference_label, #scan, #strftime, #time_standard, #to_clock_time, #to_date, #to_datetime, #to_f, #to_i, #to_residue, #to_time, #to_uri, #to_uri_escape, #universal_time, #week_included, #year_included

Methods included from Coordinates

to_deg, to_deg_225, to_dms, utf_gets

Methods included from When

Border, Calendar, CalendarEra, CalendarNote, Clock, Duration, Index, Location, M17n, MonthName, Pair, Residue, Resource, TemporalPosition, Wikipedia, _const_missing, _define_common_calendar_types, _setup_, _setup_info, at, client, column, config, const_missing, date_or_era, era, free_conv, m17n, now, server, strptime, today, when?, where?

Methods included from TemporalPosition::Conversion

#julian_date, #tm_pos

Methods included from Parts::Resource

#[], #^, _abbreviation_to_iri, _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, #parent, #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:



214
215
216
# File 'lib/when_exe/tmptypes.rb', line 214

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

._t_to_d(t) ⇒ Numeric

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

Parameters:

Returns:



203
204
205
# File 'lib/when_exe/tmptypes.rb', line 203

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

.parse(specification, options = {}) ⇒ When::TM::TemporalPosition, ...

Generation of Temporal Objetct

Parameters:

  • specification (String)

    ユリウス通日を表す文字列

  • options (Hash) (defaults to: {})

    暦法や時法などの指定 (see TemporalPosition._instance)

Returns:



225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/when_exe/tmptypes.rb', line 225

def parse(specification, options={})
  num, *calendars = specification.split(/\^{1,2}/)
  jdn  = num.sub!(/[.@]/, '.') ? num.to_f : num.to_i
  case num
  when /MJD/i ; jdn += JDN_of_MJD
  when /CEP/i ; jdn += JDN_of_CEP
  when /DTB/i ; jdn  = time_standard(options).from_dynamical_date(jdn)
  end
  frame = calendars.shift || options[:frame]
  return self.new(jdn, options) unless frame
  calendars.unshift(frame).inject(jdn) {|date, calendar| When.Calendar(calendar).jul_trans(date, options)}
end

Instance Method Details

#%(other) ⇒ Numeric

ユリウス日の剰余

Parameters:

Returns:

Raises:

  • (TypeError)


298
299
300
301
302
# File 'lib/when_exe/tmptypes.rb', line 298

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)


283
284
285
286
287
288
289
290
# File 'lib/when_exe/tmptypes.rb', line 283

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

加算



259
260
261
262
263
# File 'lib/when_exe/tmptypes.rb', line 259

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

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

減算



271
272
273
274
275
# File 'lib/when_exe/tmptypes.rb', line 271

def -(other)
  new_date = super
  new_date.frame = new_date.frame._daylight(new_date.universal_time) if new_date.kind_of?(TimeValue) && 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:



897
898
899
# File 'lib/when_exe/inspect.rb', line 897

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

#to_s(precision = @precision) ⇒ String

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

Parameters:

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

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

Returns:



907
908
909
910
# File 'lib/when_exe/inspect.rb', line 907

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