Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

Your reasoning is excellent -- it's only your basic assumptions that are wrong.


comp / comp.lang.python / Re: Timezone in HH:MM Format

SubjectAuthor
* Timezone in HH:MM FormatIvan \"Rambius\" Ivanov
`* Re: Timezone in HH:MM FormatJon Ribbens
 `- Re: Timezone in HH:MM FormatIvan \"Rambius\" Ivanov

1
Subject: Timezone in HH:MM Format
From: Ivan \Rambius\ Ivano
Newsgroups: comp.lang.python
Date: Tue, 18 Jun 2024 23:32 UTC
References: 1
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: rambiusparkisanius@gmail.com (Ivan \"Rambius\" Ivanov)
Newsgroups: comp.lang.python
Subject: Timezone in HH:MM Format
Date: Tue, 18 Jun 2024 19:32:17 -0400
Lines: 28
Message-ID: <mailman.156.1718753550.2909.python-list@python.org>
References: <CAE9rwzP8rQe=-6b1jPdDr6rgG+fVztiQbQEWM5Z6Jhj44maNLw@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de nUKH77kw/1UrKWncR1jpHArPzOxooOmGmmyoASBZ77nA==
Cancel-Lock: sha1:Ihy8o50JS8yYAoBl505Pslhfdec= sha256:V7D3wMjJXngVTYSpVpbnnHvd0q7FJrTEfucLdXT1u+o=
Return-Path: <rambiusparkisanius@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=mxQHcJ8v;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.071
X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'datetime': 0.09; 'prints':
0.09; 'import': 0.15; 'date,': 0.16; 'received:mail-
ej1-x635.google.com': 0.16; 'shell:': 0.16; 'timezone': 0.16;
'python': 0.16; 'to:addr:python-list': 0.20; 'command': 0.23;
'skip:+ 20': 0.26; 'skip:d 60': 0.26; 'to:name:python': 0.32;
'message-id:@mail.gmail.com': 0.32; 'able': 0.34; 'same': 0.34;
'appreciated.': 0.34; 'skip:" 20': 0.34; 'received:google.com':
0.34; 'skip:2 20': 0.35; 'from:addr:gmail.com': 0.35; 'hello,':
0.40; 'skip:h 10': 0.61; 'above': 0.62; 'format': 0.62; 'ivan':
0.64; 'subject::': 0.83; 'mega': 0.84; 'url-ip:195/8': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1718753548; x=1719358348; darn=python.org;
h=to:subject:message-id:date:from:mime-version:from:to:cc:subject
:date:message-id:reply-to;
bh=m/S399q81okmw3q9azY8lKLObaPafLyTCDu1AzhNM94=;
b=mxQHcJ8vTS0f8xauAaMxIgN0qHtPI2ai4kKNXzk8gypN1Xj9hKL9Pb8U2Hxr94xAZ4
4OlUq6yzYZKz1Rt4YD9mR5P2HPnUr4w6s1ylTEhQNJoswMAHEPS6OOU6EahvADwyPY4m
jP+IMU9n7Nf0R54OiWisXckW6Psmo0N99VKXTgf6eyCP7cezQ7I861jQ8kSqzLhUuLY8
7z6NUhCaeLV64fnuX71AnJn2KBucktW6zEqqg+7W8fn1krwfqRpsmRJj6+/NdJSSdwfv
fwhEg7mL4jlYexHxnDe1PaYSLuEt9Qigy9kxa0d+YN0XeqhCyVx4Uh8Sa5vA2GvWEbLq
kANQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1718753548; x=1719358348;
h=to:subject:message-id:date:from:mime-version:x-gm-message-state
:from:to:cc:subject:date:message-id:reply-to;
bh=m/S399q81okmw3q9azY8lKLObaPafLyTCDu1AzhNM94=;
b=Rp1YHqYxbwRP317EDLnL4lQDbCEFBzkbmvLvZ/KgaJStyxD2/vEO8xRzvkILHwK++H
TL7uGQzY7MKiHWloMjtToXwEF4HBILnCwuLtugX7UDxeuTCVYRFS4fVVDNHIyS8a355S
Pkw9qh8lK+3Ir4vrxl+he1YK3ofIUmFzVtmHjlLThNIyozPZSF9IZoGOvE7TG7LxBnCZ
dph0ccV31oslxUTaS/NgJBMLTYfNBZPHUpZObCqbfu2QSqv58Zp8b07qkrwnkqzsSFdj
ymFSn+9eFdKZdz4spOgMqJQHVi0wU57Vtm4cOtr3CM8NJIoK4xjlh2tBf0UcKXoyPb4Z
sSGQ==
X-Gm-Message-State: AOJu0YzYpljDV/1U4WW81AxMxT+tXyEzZtr/qNiIN0yRipJ1r8mTY/NQ
aWgFC3lbSpp15pJvafsjPbvYPsEkN/G9XLgK8OL3psdP/fbQl9l4ohGdauYTAWYLOXKmq71FVBb
rkXLZoe67TK7fG5B3ByYm6CujN9EYTnQT
X-Google-Smtp-Source: AGHT+IGT4IIAwwoFRskx1MRb2zvUk6OlWNUOu6Ty+JrZf9e/6Pv3+XEYetRmvqiMbkjqGxmugZx480pj53jk7ut7rDM=
X-Received: by 2002:a17:907:8a85:b0:a6f:adf7:b077 with SMTP id
a640c23a62f3a-a6fadf7b0f9mr18395566b.28.1718753548349; Tue, 18 Jun 2024
16:32:28 -0700 (PDT)
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAE9rwzP8rQe=-6b1jPdDr6rgG+fVztiQbQEWM5Z6Jhj44maNLw@mail.gmail.com>
View all headers

Hello,

How can I convert a date, usually datetime.now(), into a format where
the timezone is in hours:minutes format. I was able to get that format
in shell:

$ date +%Y-%m-%dT%H:%M:%S%:z
2024-06-18T19:24:09-04:00

The closest I got in python is

from datetime import datetime
from zoneinfo import ZoneInfo

s = datetime.strftime(datetime.now(ZoneInfo("America/New_York")),
"%Y-%m-%dT%H:%M:%S%z")
print(s)

This prints the same as the shell command above except the last column:
2024-06-18T19:28:56-0400

Any help will be appreciated.

Regards
Ivan

--
Tangra Mega Rock: http://www.radiotangra.com

Subject: Re: Timezone in HH:MM Format
From: Jon Ribbens
Newsgroups: comp.lang.python
Organization: A noiseless patient Spider
Date: Wed, 19 Jun 2024 00:12 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: comp.lang.python
Subject: Re: Timezone in HH:MM Format
Date: Wed, 19 Jun 2024 00:12:28 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <slrnv748jc.4u09.jon+usenet@raven.unequivocal.eu>
References: <CAE9rwzP8rQe=-6b1jPdDr6rgG+fVztiQbQEWM5Z6Jhj44maNLw@mail.gmail.com>
<mailman.156.1718753550.2909.python-list@python.org>
Injection-Date: Wed, 19 Jun 2024 02:12:29 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="19cf21608271e2dfc52f92be3ff6c24b";
logging-data="1689634"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/9rHb9Bs0qF3Kg/WEcxSoJfFbRSNJdFIs="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:vYtZpaSEhmaZtcN4aYZucMPtJ8s=
View all headers

On 2024-06-18, Ivan "Rambius" Ivanov <rambiusparkisanius@gmail.com> wrote:
> Hello,
>
> How can I convert a date, usually datetime.now(), into a format where
> the timezone is in hours:minutes format. I was able to get that format
> in shell:
>
> $ date +%Y-%m-%dT%H:%M:%S%:z
> 2024-06-18T19:24:09-04:00
>
> The closest I got in python is
>
> from datetime import datetime
> from zoneinfo import ZoneInfo
>
> s = datetime.strftime(datetime.now(ZoneInfo("America/New_York")),
> "%Y-%m-%dT%H:%M:%S%z")
> print(s)
>
> This prints the same as the shell command above except the last column:
> 2024-06-18T19:28:56-0400
>
> Any help will be appreciated.

datetime.now(ZoneInfo("America/New_York")).isoformat()

Subject: Re: Timezone in HH:MM Format
From: Ivan \Rambius\ Ivano
Newsgroups: comp.lang.python
Date: Wed, 19 Jun 2024 02:15 UTC
References: 1 2 3 4
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: rambiusparkisanius@gmail.com (Ivan \"Rambius\" Ivanov)
Newsgroups: comp.lang.python
Subject: Re: Timezone in HH:MM Format
Date: Tue, 18 Jun 2024 22:15:25 -0400
Lines: 12
Message-ID: <mailman.158.1718763340.2909.python-list@python.org>
References: <CAE9rwzP8rQe=-6b1jPdDr6rgG+fVztiQbQEWM5Z6Jhj44maNLw@mail.gmail.com>
<mailman.156.1718753550.2909.python-list@python.org>
<slrnv748jc.4u09.jon+usenet@raven.unequivocal.eu>
<CAE9rwzPEXe1GCnsYV+u8-fTAjBBv56zPZbtSPZf2QMJfzcD5Rg@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de q8+EysXhlJ0ihEqNW5K5NQpKm1yXuxquNc5AbBqGIdjQ==
Cancel-Lock: sha1:XG1sssQ4YagR3SaHdaFCQnRC1MM= sha256:IhKQpx3VSfb7dqeljGcWvLetr0k9XnyrnYUZ4+WaYqU=
Return-Path: <rambiusparkisanius@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=dgFIF4z/;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.105
X-Spam-Level: *
X-Spam-Evidence: '*H*': 0.82; '*S*': 0.03; '18,': 0.09; 'cc:addr
:python-list': 0.09; 'cc:no real name:2**0': 0.14; '2024': 0.16;
'wrote:': 0.16; 'tue,': 0.19; 'cc:addr:python.org': 0.20;
'cc:2**0': 0.25; 'jun': 0.26; 'python-list': 0.32; 'message-
id:@mail.gmail.com': 0.32; 'work.': 0.34; 'header:In-Reply-To:1':
0.34; 'received:google.com': 0.34; 'from:addr:gmail.com': 0.35;
'both': 0.40; 'your': 0.64; 'subject::': 0.83; 'jon': 0.84;
'mega': 0.84; 'url-ip:195/8': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1718763337; x=1719368137; darn=python.org;
h=content-transfer-encoding:cc:to:subject:message-id:date:from
:in-reply-to:references:mime-version:from:to:cc:subject:date
:message-id:reply-to;
bh=egT4nHkio//6kcbj4HEoqNdODPEvNd6d4hHG7xjxC6o=;
b=dgFIF4z/ywdsq4cWd+4BBcAgTRgZx89/bgUrzn4YzXgTTrIT/upOi2rfWdf2l4GcOy
6KMJ4cGdbE4BdA7rWbmjvLBlZyeNvudiHULZoGglkHGaD79VsZ07yP1dOZjl/NXLxcRx
HFXvE3RKQDl9MgWv/SX7LiJmdeeTq0kEGQsHT5Ag6FE2DapZL7FDo40Bo3Rs3A6ATtx1
EsmSt97EuF0s7zgoWLjb71xfdFHIpVtSo6TPJ4zvk/OefC4+q3TleWizqDcb+hLaoRVG
tlV85ypT+Vl+2eacRnRz79PmRFiFHim+zBbzvRO6crm6PMyW6i2ilJtnHssjmfQQxgY8
A/Pg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1718763337; x=1719368137;
h=content-transfer-encoding:cc:to:subject:message-id:date:from
:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc
:subject:date:message-id:reply-to;
bh=egT4nHkio//6kcbj4HEoqNdODPEvNd6d4hHG7xjxC6o=;
b=pKB4AevvU6HAanM1zM5gIpFMW7Eq8vwIhmHwWnTASU2Tw/bCrry+G9hLxg+Oc/BCEG
CZffdQh+9ftv8odY5T1187TZX5EVFTnv4sVL6MbArh6WRP/TndLsfL1b8FeSkeAqPnDJ
AWhoLqjoa93FvGl5aP1u+mySygbzbI3Ms97jc0cby0v2g6LmGZzddaNOhPNdsmqxF64w
FvsJD7jhvD4jLd1boYr5WSRs2yuWKnLJj6gqi2MmeWaTb/e5imEH1M4Q7YsAjb4qL+LC
VPkkQpCIWFz3EagBtieKh0Hj+lxtGJakYVZApcfIrdnZeeYWOF+MUZG5bWEfRz5nz6s3
6qTQ==
X-Gm-Message-State: AOJu0YxHPz27ufLLE6//B/xzEVVbozyw+pJ6AFKEhOd5ai3uxPc/LH9Y
VTvrp18prncmhEhLWGKxUqpDQxwY6d1FJYu1nY8af8S5Q55udy7erHa4ucXGmXaKVbhCeAs9hwN
iqLengT9EKG68QFf31qKQWL3qRY4=
X-Google-Smtp-Source: AGHT+IGOpgenrx4G5JxHmvz51dWQLL1aycFEyeOSlc7BAo4KeoEg0s4dt+gyctviCnC4nsDbUgtVHxcPgk1v5T0ktZU=
X-Received: by 2002:aa7:c392:0:b0:57d:107e:dd79 with SMTP id
4fb4d7f45d1cf-57d107edd96mr30351a12.26.1718763337245; Tue, 18 Jun 2024
19:15:37 -0700 (PDT)
In-Reply-To: <slrnv748jc.4u09.jon+usenet@raven.unequivocal.eu>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAE9rwzPEXe1GCnsYV+u8-fTAjBBv56zPZbtSPZf2QMJfzcD5Rg@mail.gmail.com>
X-Mailman-Original-References: <CAE9rwzP8rQe=-6b1jPdDr6rgG+fVztiQbQEWM5Z6Jhj44maNLw@mail.gmail.com>
<mailman.156.1718753550.2909.python-list@python.org>
<slrnv748jc.4u09.jon+usenet@raven.unequivocal.eu>
View all headers

Thank you all for your responses!

On Tue, Jun 18, 2024 at 9:54 PM Jon Ribbens via Python-list
<python-list@python.org> wrote:
>
> datetime.now(ZoneInfo("America/New_York")).isoformat()

Both .isoformat() and "%:z" work.

--
Tangra Mega Rock: http://www.radiotangra.com

1

rocksolid light 0.9.8
clearnet tor