Rocksolid Light

News from da outaworlds

mail  files  register  groups  login

Message-ID:  

BOFH excuse #69: knot in cables caused data stream to become twisted and kinked


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

SubjectAuthor
o Re: Timezone in HH:MM FormatMRAB

1
Subject: Re: Timezone in HH:MM Format
From: MRAB
Newsgroups: comp.lang.python
Date: Tue, 18 Jun 2024 23:52 UTC
References: 1 2
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: python@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re: Timezone in HH:MM Format
Date: Wed, 19 Jun 2024 00:52:07 +0100
Lines: 24
Message-ID: <mailman.157.1718754916.2909.python-list@python.org>
References: <CAE9rwzP8rQe=-6b1jPdDr6rgG+fVztiQbQEWM5Z6Jhj44maNLw@mail.gmail.com>
<b8a399a8-9d2b-4e83-8823-3b10669f5a0e@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de ilqYLPCbm1hzJgSe0EoeyAphnqcd3Pneac3v8+w2XDYQ==
Cancel-Lock: sha1:lbAZyU4pEdnIMnhn6TvEkw76bJw= sha256:dgrzB6ENJTPK/71Cqydx0Uqnc7VoGKGI05D5siZhjTM=
Return-Path: <python@mrabarnett.plus.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=plus.com header.i=@plus.com header.b=LXJBQh5f;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.004
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'string': 0.07; 'datetime':
0.09; 'from:addr:python': 0.09; 'prints': 0.09;
'received:192.168.1.64': 0.09; 'import': 0.15; 'date,': 0.16;
'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16;
'message-id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16;
'received:84.93.230': 0.16; 'received:plus.net': 0.16; 'shell:':
0.16; 'timezone': 0.16; 'wrote:': 0.16; 'python': 0.16; 'to:addr
:python-list': 0.20; 'command': 0.23; 'python,': 0.25; 'skip:+
20': 0.26; 'skip:d 60': 0.26; 'header:User-Agent:1': 0.30;
'python-list': 0.32; 'received:192.168.1': 0.32; 'able': 0.34;
'same': 0.34; 'skip:" 20': 0.34; 'header:In-Reply-To:1': 0.34;
'skip:2 20': 0.35; 'received:192.168': 0.37; 'use': 0.39;
'hello,': 0.40; 'skip:h 10': 0.61; 'above': 0.62; 'format': 0.62;
'ivan': 0.64; 'earlier': 0.67; 'subject::': 0.83
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1718754729; bh=jTpIt5Pt9DhlDvxBgNH85AqX6Qbk1tXyd9ab0ypdU5I=;
h=Date:Subject:To:References:From:In-Reply-To;
b=LXJBQh5f/utzqc1gVIrP+0D7iklQJWWQGm5OKBF4gy3NaHvFw0fB5dMfiHGsy6egW
SkDOnWVgcQTHkzLjFGimZgLGQtgQ2qXZ5azDVs/efME8pfKNjSx+lUwCUSu6b0LO7Z
YogVidGyDmUG4MryFcji9KNlyzAfvlxJ8S0LEnBC0uidPR1xOpI4T7Pk7QprulSXxE
RxbFVG3gtBXAOClm5zuS0Q/PgKlYoZlMNRZ0JnHF0H8CGvLOwwf2XRZ4ntV15jqolv
5lt1ZceZGVcJEyAlSlYO+qVnELIk5ldt58Ys4AUGK56pp6/ijQWZfskb2iBNmIP62h
PyY2dyPMw3qXQ==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=DtP1+3/+ c=1 sm=1 tr=0 ts=66721da9
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=_tp2UMK4TxSY2kXOoLkA:9 a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla Thunderbird
Content-Language: en-GB
In-Reply-To: <CAE9rwzP8rQe=-6b1jPdDr6rgG+fVztiQbQEWM5Z6Jhj44maNLw@mail.gmail.com>
X-CMAE-Envelope: MS4xfCnr2IvYaTwVGz+gRRG34dRgW66x/ICBjnaZsV59P/MrYIWFF//IcGiP2OYBkeU2EEn4t6qQlwY9EMkqd07AlfuzE5kQkOB9rkGOltHWbjNkIVLMykCv
/4D20aAVglozBU3HAOgYnVoRd5n1+BopGXVXRiJvq7Vv1yJjjmILWucSfzeDz0c5Mi3yWLX9xrXBKhwU8i/JaOJERSxQKaQYPUI=
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: <b8a399a8-9d2b-4e83-8823-3b10669f5a0e@mrabarnett.plus.com>
X-Mailman-Original-References: <CAE9rwzP8rQe=-6b1jPdDr6rgG+fVztiQbQEWM5Z6Jhj44maNLw@mail.gmail.com>
View all headers

On 2024-06-19 00:32, Ivan "Rambius" Ivanov via Python-list 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
>
Starting from Python 3.12, you can use "%:z" in the format string. For
earlier versions of Python, you need to do some string slicing.

1

rocksolid light 0.9.8
clearnet tor