{"id":1910,"date":"2024-08-07T13:44:27","date_gmt":"2024-08-07T12:44:27","guid":{"rendered":"https:\/\/blog.univ-angers.fr\/mathsinfo\/?p=1910"},"modified":"2024-08-09T07:47:07","modified_gmt":"2024-08-09T06:47:07","slug":"representation-du-temps-dans-les-systemes-informatiques","status":"publish","type":"post","link":"https:\/\/blog.univ-angers.fr\/mathsinfo\/2024\/08\/07\/representation-du-temps-dans-les-systemes-informatiques\/","title":{"rendered":"Repr\u00e9sentation du temps &#8211; Dans les syst\u00e8mes informatiques"},"content":{"rendered":"\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Repr\u00e9sentation du temps - Dans les syst\u00e8mes informatiques\" width=\"584\" height=\"329\" src=\"https:\/\/www.youtube.com\/embed\/MpgJIo4a9A8?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n\n\n\n<p><span style=\"text-decoration: underline\">Remarque sur les calculatrices TI<\/span> : comme pr\u00e9cis\u00e9 dans la vid\u00e9o, la fonction <strong>dbd<\/strong> des TI-82\/83\/84 permet de trouver le nombre de jours entre 2 dates entre 1950 et 2049. Cependant, sur les <strong>TI-84 Plus CE<\/strong> cette plage a \u00e9t\u00e9 d\u00e9cal\u00e9e \u00e0 l&rsquo;intervalle 1980 &#8211; 2079.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Temps unix<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>import datetime\nfrom datetime import timezone\n\ndt = datetime.datetime(2024,8,5,14,33,17, tzinfo=timezone.utc)\n&gt;&gt;&gt; dt.timestamp()\n1722868397.0\n\nimport time\n&gt;&gt;&gt; time.gmtime(1722868397.0)\ntime.struct_time(tm_year=2024, tm_mon=8, tm_mday=5, tm_hour=14, tm_min=33, tm_sec=17, tm_wday=0, tm_yday=218, tm_isdst=0)\n\n&gt;&gt;&gt; time.gmtime(0)\ntime.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)\n\n&gt;&gt;&gt; time.gmtime(-2000 * 365 * 86400)\ntime.struct_time(tm_year=-29, tm_mon=5, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=5, tm_yday=121, tm_isdst=0)\n\n&gt;&gt;&gt; time.time()\n1722867076.132498\n\n&gt;&gt;&gt; datetime.datetime.now(timezone.utc).timestamp()\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Date de p\u00e2ques (Formule approximative !)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>def paques(annee):\n    cycle_lune = 29.53058853\n    j_sem = 6  # Samedi 5\/1\/1901\n    delta = nb_jours(5, 1, 1901, 21, 3, annee)\n    nb_cycles = 1 + int(delta \/ cycle_lune)\n    ajout = int(nb_cycles * cycle_lune)\n    while (j_sem + ajout) % 7 != 0: ajout +=1\n    nb = ajout - delta\n    if nb &lt;= 10: j, m = 21 + nb, 3\n    else: j, m = nb - 10, 4\n    return (m, j)\n\ndef formule(j,m,a):\n    if m &lt; 3:\n        a -= 1\n        m += 12\n    return int(365.25 * a) + int(30.6 * (m + 1)) + j - 3\n\ndef nb_jours(j1, m1, a1, j2, m2, a2):\n    return formule(j2, m2, a2) - formule(j1, m1, a1)\n\ndef dow(j,m,a): return 1 + (formule(j,m,a) % 7)\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Date de p\u00e2ques (formule exacte)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>def easter(annee):\n    a = annee % 19\n    b = annee \/\/ 100\n    c = annee % 100\n    d = b \/\/ 4\n    e = b % 4\n    f = (b + 8) \/\/ 25\n    g = (b - f + 1) \/\/ 3\n    h = (19 * a + b - d - g + 15) % 30\n    i = c \/\/ 4\n    k = c % 4\n    l = (32 + 2 * e + 2 * i - h - k) % 7\n    m = (a + 11 * h + 22 * l) \/\/ 451\n    mois = (h + l - 7 * m + 114) \/\/ 31\n    jour = ((h + l - 7 * m + 114) % 31) + 1\n    return (annee, mois, jour)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Remarque sur les calculatrices TI : comme pr\u00e9cis\u00e9 dans la vid\u00e9o, la fonction dbd des TI-82\/83\/84 permet de trouver le nombre de jours entre 2 dates entre 1950 et 2049. Cependant, sur les TI-84 Plus CE cette plage a \u00e9t\u00e9 &hellip; <a href=\"https:\/\/blog.univ-angers.fr\/mathsinfo\/2024\/08\/07\/representation-du-temps-dans-les-systemes-informatiques\/\">Continuer la lecture <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":4913,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1910","post","type-post","status-publish","format-standard","hentry","category-non-classe"],"_links":{"self":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1910","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/users\/4913"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/comments?post=1910"}],"version-history":[{"count":4,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1910\/revisions"}],"predecessor-version":[{"id":1914,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/posts\/1910\/revisions\/1914"}],"wp:attachment":[{"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/media?parent=1910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/categories?post=1910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.univ-angers.fr\/mathsinfo\/wp-json\/wp\/v2\/tags?post=1910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}