Class: When::TM::JulianDate

Inherits:
Coordinate show all
Defined in:
lib/when_exe/tmposition.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::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 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, universal_time

Methods inherited from TemporalPosition

#+@, #-, #<=>, #==, #[], #^, #_attr, _instance, #_notes, _options, _setup_, _setup_info, _temporal_position, #_to_h, #_to_s, _verify, #calendar_name, #clock_name, #copy, #dynamical_time, #floor, format, #has_next?, #has_time?, #include?, #inspect, #is?, #month_included, #note?, #notes, #period, #prev, #rate_of_clock, #reference_label, #scan, #strftime, #succ, #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

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, era, free_conv, m17n, now, server, today, when?

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, #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:



1329
1330
1331
# File 'lib/when_exe/tmposition.rb', line 1329

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

._t_to_d(t) ⇒ Numeric

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

Parameters:

Returns:



1318
1319
1320
# File 'lib/when_exe/tmposition.rb', line 1318

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:



1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
# File 'lib/when_exe/tmposition.rb', line 1340

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
  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)


1386
1387
1388
1389
1390
# File 'lib/when_exe/tmposition.rb', line 1386

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)


1371
1372
1373
1374
1375
1376
1377
1378
# File 'lib/when_exe/tmposition.rb', line 1371

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

加算



1359
1360
1361
1362
1363
# File 'lib/when_exe/tmposition.rb', line 1359

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:



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