summaryrefslogtreecommitdiffstats
path: root/src/kadmin/server/ChangeLog
diff options
context:
space:
mode:
authorTom Yu <tlyu@mit.edu>1994-08-09 20:47:31 +0000
committerTom Yu <tlyu@mit.edu>1994-08-09 20:47:31 +0000
commit41cce679aa1d85fbf605537f6a7385ba9b4c73f0 (patch)
tree75638b9a161ac6f767aefb764df8f1e2ea9a6102 /src/kadmin/server/ChangeLog
parent52c4e5a30002b791e4aac761e8ec782c972db448 (diff)
* Makefile.in: oops forgot about $(COMERRLIB)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@4097 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/kadmin/server/ChangeLog')
0 files changed, 0 insertions, 0 deletions
ef='#n91'>91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
# format.rb: Written by Tadayoshi Funaba 1999-2004
# $Id: format.rb,v 2.12 2004-01-19 05:43:28+09 tadf Exp $

class Date

  MONTHS = {
    'january'  => 1, 'february' => 2, 'march'    => 3, 'april'    => 4,
    'may'      => 5, 'june'     => 6, 'july'     => 7, 'august'   => 8,
    'september'=> 9, 'october'  =>10, 'november' =>11, 'december' =>12
  }

  DAYS = {
    'sunday'   => 0, 'monday'   => 1, 'tuesday'  => 2, 'wednesday'=> 3,
    'thursday' => 4, 'friday'   => 5, 'saturday' => 6
  }

  ABBR_MONTHS = {
    'jan'      => 1, 'feb'      => 2, 'mar'      => 3, 'apr'      => 4,
    'may'      => 5, 'jun'      => 6, 'jul'      => 7, 'aug'      => 8,
    'sep'      => 9, 'oct'      =>10, 'nov'      =>11, 'dec'      =>12
  }

  ABBR_DAYS = {
    'sun'      => 0, 'mon'      => 1, 'tue'      => 2, 'wed'      => 3,
    'thu'      => 4, 'fri'      => 5, 'sat'      => 6
  }

  ZONES = {
    'ut'  =>  0*3600, 'gmt' =>  0*3600, 'est' => -5*3600, 'edt' => -4*3600,
    'cst' => -6*3600, 'cdt' => -5*3600, 'mst' => -7*3600, 'mdt' => -6*3600,
    'pst' => -8*3600, 'pdt' => -7*3600,
    'a'   =>  1*3600, 'b'   =>  2*3600, 'c'   =>  3*3600, 'd'   =>  4*3600,
    'e'   =>  5*3600, 'f'   =>  6*3600, 'g'   =>  7*3600, 'h'   =>  8*3600,
    'i'   =>  9*3600, 'k'   => 10*3600, 'l'   => 11*3600, 'm'   => 12*3600,
    'n'   => -1*3600, 'o'   => -2*3600, 'p'   => -3*3600, 'q'   => -4*3600,
    'r'   => -5*3600, 's'   => -6*3600, 't'   => -7*3600, 'u'   => -8*3600,
    'v'   => -9*3600, 'w'   =>-10*3600, 'x'   =>-11*3600, 'y'   =>-12*3600,
    'z'   =>  0*3600,
    'utc' =>  0*3600, 'wet' =>  0*3600, 'bst' =>  1*3600, 'wat' => -1*3600,
    'at'  => -2*3600, 'ast' => -4*3600, 'adt' => -3*3600, 'yst' => -9*3600,
    'ydt' => -8*3600, 'hst' =>-10*3600, 'hdt' => -9*3600, 'cat' =>-10*3600,
    'ahst'=>-10*3600, 'nt'  =>-11*3600, 'idlw'=>-12*3600, 'cet' =>  1*3600,
    'met' =>  1*3600, 'mewt'=>  1*3600, 'mest'=>  2*3600, 'mesz'=>  2*3600,
    'swt' =>  1*3600, 'sst' =>  2*3600, 'fwt' =>  1*3600, 'fst' =>  2*3600,
    'eet' =>  2*3600, 'bt'  =>  3*3600, 'zp4' =>  4*3600, 'zp5' =>  5*3600,
    'zp6' =>  6*3600, 'wast'=>  7*3600, 'wadt'=>  8*3600, 'cct' =>  8*3600,
    'jst' =>  9*3600, 'east'=> 10*3600, 'eadt'=> 11*3600, 'gst' => 10*3600,
    'nzt' => 12*3600, 'nzst'=> 12*3600, 'nzdt'=> 13*3600, 'idle'=> 12*3600
  }

  def self.__strptime(str, fmt, elem)
    fmt.scan(/%[EO]?.|./o) do |c|
      cc = c.sub(/\A%[EO]?(.)\Z/o, '%\\1')
      case cc
      when /\A\s/o
	str.sub!(/\A[\s\v]+/o, '')
      when '%A', '%a'
	return unless str.sub!(/\A([a-z]+)\b/io, '')
	val = DAYS[$1.downcase] || ABBR_DAYS[$1.downcase]
	return unless val
	elem[:wday] = val
      when '%B', '%b', '%h'
	return unless str.sub!(/\A([a-z]+)\b/io, '')
	val = MONTHS[$1.downcase] || ABBR_MONTHS[$1.downcase]
	return unless val
	elem[:mon] = val
      when '%C'
	return unless str.sub!(/\A(\d+)/o, '')
	val = $1.to_i
	elem[:cent] = val
      when '%c'
	return unless __strptime(str, '%a %b %e %H:%M:%S %Y', elem)
      when '%D'
	return unless __strptime(str, '%m/%d/%y', elem)
      when '%d', '%e'
	return unless str.sub!(/\A ?(\d+)/o, '')
	val = $1.to_i
	return unless (1..31) === val
	elem[:mday] = val
      when '%F'
	return unless __strptime(str, '%Y-%m-%d', elem)
      when '%G'
	return unless str.sub!(/\A([-+]?\d+)/o, '')
	val = $1.to_i
	elem[:cwyear] = val
      when '%g'
	return unless str.sub!(/\A(\d+)/o, '')
	val = $1.to_i
	return unless (0..99) === val
	elem[:cwyear] = val
	elem[:cent] ||= if val >= 69 then 19 else 20 end
      when '%H', '%k'
	return unless str.sub!(/\A ?(\d+)/o, '')
	val = $1.to_i
	return unless (0..24) === val
	elem[:hour] = val
      when '%I', '%l'
	return unless str.sub!(/\A ?(\d+)/o, '')
	val = $1.to_i
	return unless (1..12) === val
	elem[:hour] = val
      when '%j'
	return unless str.sub!(/\A(\d+)/o, '')
	val = $1.to_i
	return unless (1..366) === val
	elem[:yday] = val
      when '%M'
	return unless str.sub!(/\A(\d+)/o, '')
	val = $1.to_i
	return unless (0..59) === val
	elem[:min] = val
      when '%m'
	return unless str.sub!(/\A(\d+)/o, '')
	val = $1.to_i
	return unless (1..12) === val
	elem[:mon] = val
      when '%n'
	return unless __strptime(str, ' ', elem)
      when '%p', '%P'
	return unless str.sub!(/\A([ap])(?:m\b|\.m\.)/io, '')
	elem[:merid] = if $1.downcase == 'a' then 0 else 12 end
      when '%R'
	return unless __strptime(str, '%H:%M', elem)
      when '%r'
	return unless __strptime(str, '%I:%M:%S %p', elem)
      when '%S'
	return unless str.sub!(/\A(\d+)/o, '')
	val = $1.to_i
	return unless (0..60) === val
	elem[:sec] = val
      when '%s'
	return unless str.sub!(/\A(\d+)/o, '')
	val = $1.to_i
	elem[:seconds] = val
      when '%T'
	return unless __strptime(str, '%H:%M:%S', elem)
      when '%t'
	return unless __strptime(str, ' ', elem)
      when '%U', '%W'
	return unless str.sub!(/\A(\d+)/o, '')
	val = $1.to_i
	return unless (0..53) === val
	elem[if c == '%U' then :wnum0 else :wnum1 end] = val
      when '%u'
	return unless str.sub!(/\A(\d+)/o, '')
	val = $1.to_i
	return unless (1..7) === val
	elem[:cwday] = val
      when '%V'
	return unless str.sub!(/\A(\d+)/o, '')
	val = $1.to_i
	return unless (1..53) === val
	elem[:cweek] = val
      when '%v'
	return unless __strptime(str, '%e-%b-%Y', elem)
      when '%w'
	return unless str.sub!(/\A(\d+)/o, '')
	val = $1.to_i
	return unless (0..6) === val
	elem[:wday] = val
      when '%X'
	return unless __strptime(str, '%H:%M:%S', elem)
      when '%x'
	return unless __strptime(str, '%m/%d/%y', elem)
      when '%Y'
	return unless str.sub!(/\A([-+]?\d+)/o, '')
	val = $1.to_i
	elem[:year] = val
      when '%y'
	return unless str.sub!(/\A(\d+)/o, '')
	val = $1.to_i
	return unless (0..99) === val
	elem[:year] = val
	elem[:cent] ||= if val >= 69 then 19 else 20 end
      when '%Z', '%z'
	return unless str.sub!(/\A([-+:a-z0-9]+(?:\s+dst\b)?)/io, '')
	val = $1
	elem[:zone] = val
	offset = zone_to_diff(val)
	elem[:offset] = offset
      when '%%'
	return unless str.sub!(/\A%/o, '')
      when '%+'
	return unless __strptime(str, '%a %b %e %H:%M:%S %Z %Y', elem)
      when '%1'
	return unless str.sub!(/\A(\d+)/o, '')
	val = $1.to_i
	elem[:jd] = val
      when '%2'
	return unless __strptime(str, '%Y-%j', elem)
      when '%3'
	return unless __strptime(str, '%F', elem)
      else
	return unless str.sub!(Regexp.new('\\A' + Regexp.quote(c)), '')
      end
    end

    if cent = elem.delete(:cent)
      if elem[:cwyear]
	elem[:cwyear] += cent * 100
      end
      if elem[:year]
	elem[:year] += cent * 100
      end
    end

    if merid = elem.delete(:merid)
      if elem[:hour]
	elem[:hour] %= 12
	elem[:hour] += merid
      end
    end

    str
  end

  private_class_method :__strptime

  def self._strptime(str, fmt='%F')
    elem = {}
    elem if __strptime(str.dup, fmt, elem)
  end

  PARSE_MONTHPAT = ABBR_MONTHS.keys.join('|')
  PARSE_DAYPAT   = ABBR_DAYS.  keys.join('|')

  def self._parse(str, comp=false)
    str = str.dup

    str.gsub!(/[^-+.\/:0-9a-z]+/ino, ' ')

    # day
    if str.sub!(/(#{PARSE_DAYPAT})\S*/ino, ' ')
      wday = ABBR_DAYS[$1.downcase]
    end

    # time
    if str.sub!(
		/(\d+):(\d+)(?::(\d+))?
		 (?:
		   \s*
		   ([ap])(?:m\b|\.m\.)
		 )?
		 (?:
		   \s*
		   (
		     [a-z]+(?:\s+dst)?\b
		   |
		     [-+]\d+(?::?\d+)
		   )
		 )?
		/inox,
		' ')
      hour = $1.to_i
      min = $2.to_i
      sec = $3.to_i if $3

      if $4
	hour %= 12
	if $4.downcase == 'p'
	  hour += 12
	end
      end

      zone = $5
    end

    # eu
    if str.sub!(
		/(\d+)\S*
		 \s+
		 (#{PARSE_MONTHPAT})\S*
		 (?:
		   \s+
		   (-?\d+)
		 )?
		/inox,
		' ')
      mday = $1.to_i
      mon = ABBR_MONTHS[$2.downcase]

      if $3
	year = $3.to_i
	if $3.size > 2
	  comp = false
	end
      end

    # us
    elsif str.sub!(
		   /(#{PARSE_MONTHPAT})\S*
		    \s+
		    (\d+)\S*
		    (?:
		      \s+
		      (-?\d+)
		    )?
		   /inox,
		   ' ')
      mon = ABBR_MONTHS[$1.downcase]
      mday = $2.to_i

      if $3
	year = $3.to_i
	if $3.size > 2
	  comp = false
	end
      end

    # iso
    elsif str.sub!(/([-+]?\d+)-(\d+)-(-?\d+)/no, ' ')
      year = $1.to_i
      mon = $2.to_i
      mday = $3.to_i

      if $1.size > 2
	comp = false
      elsif $3.size > 2
	comp = false
	mday, mon, year = year, mon, mday
      end

    # jis
    elsif str.sub!(/([MTSH])(\d+)\.(\d+)\.(\d+)/ino, ' ')
      e = { 'm'=>1867,
	    't'=>1911,
	    's'=>1925,
	    'h'=>1988
	  }[$1.downcase]