0년 0월 0일부터 555555일 후의 날짜 계산 쉘 스크립트?

foruses의 이미지

특정 날짜(yyyy.mm.dd)로부터 특정 일(dd) 후의 날짜를 계산하고 싶습니다.

가령 0년 0월 0일부터 555555일 후가 몇년 몇월 몇일이 되는지를 말입니다.

쉘 스크립트를 어떻게 적용할 수 있을지 경험 있으신 분의 도움을 부탁드립니다. 꾸벅.

하하호로의 이미지

$ date "+%s" -d "19700101 00:00:00 UTC"
0
19700101 00:00:00 UTC가 0초입니다.

$ date "+%s" -d "19700101 09:00:00"
0
$ date "+%s" -d "19700101 09:00:00 KST"
0
한국은 9시간 빠르지요.

같은 시간대를 비교한다면 의미가 없는 것이고, 초로 변환해서 차를 계산한 후에 다시 일로 변환하면 되겠지요.

하하호호의 이미지

$ date "+%Y%m%d" -d "00000101 555555 day"
15210122

0년 1월 1일 부터 555555일 후의 연월일입니다. 0월 0일은 없지요.

jick의 이미지

정확히 말하자면 서력에는 0년도 없습니다. 서기(AD) 1년 바로 전 해는 기원전(BC) 1년입니다.

하하호호의 이미지

Year zero does not exist in the Anno Domini system usually used to number years in the Gregorian calendar and in its predecessor, the Julian calendar. In this system, the year 1 BC is followed by AD 1. However, there is a year zero in astronomical year numbering (where it coincides with the Julian year 1 BC) and in ISO 8601:2004 (where it coincides with the Gregorian year 1 BC) as well as in all Buddhist and Hindu calendars.

foruses의 이미지

그럼 정말 0년 0월 0일부터를 계산하려면 어떻게 해야할까요?

위에 고맙게 알려주신 $ date "+%Y%m%d" -d "00000101 555555 day" 에서, 년도에 마이너스를 넣어 봤는데 에러가 나서요...

하하호호의 이미지

만일 시간의 시작을 0년 0월 0일 00:00:00 정의하고 정확히 24시간, 즉 1일 후가 0년 1월 1일 00:00:00 시라면, 정확히 하루 차이가 나니 1일을 빼주면 되겠지요.

아래의 예는 0년 0월 0일 00:00:00 이후 1000일 후의 날짜입니다.

$ d=1000; date "+%Y/%m/%d" -d "00000101 $(expr $d - 1) days"
0002/09/26

cinsk의 이미지

calendar는 대단히 복잡합니다. gregorian인지 julian인지, 음력인지 등등.

현재 쓰고 있는 gregorian 기준으로 0년 0월 0일이란 존재하지 않습니다. 15xx년에 시작했거든요.

특정 날짜 A 기준, +B day 이후가 며칠인가? 란 질문에서 먼저 특절 날짜 A가 UNIX epoch 이후 (1970년)라면, A를 epoch time으로 바꾼 후, B를 더한 다음, 다시 gregorian으로 바꾸면 됩니다. (date command에 %s를 쓰면 되겠네요)

A가 unix epoch 이전 날짜이고 15xx년(gregorian 시작 날짜) 이후라면, gregorian A를 julian day로 바꾸고, B를 더한 다음, 그 날짜를 다시 gregorian으로 바꿔야 할 것 같네요.

A가 gregorian 이전 날짜라면 julian calendar일테고, 그럼 julian date A를 julian day로 바꾼후, B를 더한 다음, 그 결과를 julian calendar로 바꿔야 할 것 같네요.

만약 A가 julian day 0 (BC 47xx) 이전이라면.. 모르겠는데요? :)

김정균의 이미지

심지어는 1582.10.5~1582.10.14 는 어느 달력 상에도 존재하지 않죠 ^^

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.