Flowdock
method

_valid_nth_kday?

Importance_0
v1_9_2_180 - Show latest stable - 0 notes - Class: Date
_valid_nth_kday?(y, m, n, k, sg=GREGORIAN) public

No documentation

This method has no description. You can help the Ruby community by adding new notes.

Hide source
# File lib/date.rb, line 673
    def _valid_nth_kday? (y, m, n, k, sg=GREGORIAN) # :nodoc:
      if k < 0
        k += 7
      end
      if n < 0
        ny, nm = (y * 12 + m).divmod(12)
        nm,    = (nm + 1)    .divmod(1)
        ny, nm, nn, nk =
          jd_to_nth_kday(nth_kday_to_jd(ny, nm, 1, k, sg) + n * 7, sg)
        return unless [ny, nm] == [y, m]
        n = nn
      end
      jd = nth_kday_to_jd(y, m, n, k, sg)
      return unless [y, m, n, k] == jd_to_nth_kday(jd, sg)
      jd
    end
Register or log in to add new notes.