Browse Source

Datetime, Image draw

pull/135/head
Jure Šorn 2 years ago
parent
commit
7bacc33eb3
2 changed files with 20 additions and 20 deletions
  1. 18
      README.md
  2. 22
      index.html

18
README.md

@ -598,10 +598,10 @@ from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary
### Constructors ### Constructors
```python ```python
<D> = date(year, month, day)
<T> = time(hour=0, minute=0, second=0, microsecond=0, tzinfo=None, fold=0)
<DT> = datetime(year, month, day, hour=0, minute=0, second=0, ...)
<TD> = timedelta(weeks=0, days=0, hours=0, minutes=0, seconds=0, ...)
<D> = date(year, month, day) # Only accepts valid dates from 1 to 9999 AD.
<T> = time(hour=0, minute=0, second=0) # Also: `microsecond=0, tzinfo=None, fold=0`.
<DT> = datetime(year, month, day, hour=0) # Also: `minute=0, second=0, microsecond=0, …`.
<TD> = timedelta(weeks=0, days=0, hours=0) # Also: `minutes=0, seconds=0, microsecond=0`.
``` ```
* **Use `'<D/DT>.weekday()'` to get the day of the week as an int, with Monday being 0.** * **Use `'<D/DT>.weekday()'` to get the day of the week as an int, with Monday being 0.**
* **`'fold=1'` means the second pass in case of time jumping back for one hour.** * **`'fold=1'` means the second pass in case of time jumping back for one hour.**
@ -637,7 +637,7 @@ from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary
### Decode ### Decode
```python ```python
<str> = <D/T/DT>.isoformat(sep='T') # Also timespec='auto/hours/minutes/seconds/…'.
<str> = <D/T/DT>.isoformat(sep='T') # Also: `timespec='auto/hours/minutes/seconds/…'`.
<str> = <D/T/DT>.strftime('<format>') # Custom string representation. <str> = <D/T/DT>.strftime('<format>') # Custom string representation.
<int> = <D/DT>.toordinal() # Days since Gregorian NYE 1, ignoring time and tz. <int> = <D/DT>.toordinal() # Days since Gregorian NYE 1, ignoring time and tz.
<float> = <DTn>.timestamp() # Seconds since the Epoch, from DTn in local tz. <float> = <DTn>.timestamp() # Seconds since the Epoch, from DTn in local tz.
@ -2788,11 +2788,11 @@ from PIL import ImageDraw
```python ```python
<ImageDraw>.point((x, y)) # Truncates floats into ints. <ImageDraw>.point((x, y)) # Truncates floats into ints.
<ImageDraw>.line((x1, y1, x2, y2 [, ...])) # To get anti-aliasing use images's resize().
<ImageDraw>.line((x1, y1, x2, y2 [, ...])) # To get anti-aliasing use Image's resize().
<ImageDraw>.arc((x1, y1, x2, y2), deg1, deg2) # Always draws in clockwise direction. <ImageDraw>.arc((x1, y1, x2, y2), deg1, deg2) # Always draws in clockwise direction.
<ImageDraw>.rectangle((x1, y1, x2, y2)) # To rotate use image's rotate() and paste().
<ImageDraw>.polygon((x1, y1, x2, y2, ...)) # Last and first point get connected.
<ImageDraw>.ellipse((x1, y1, x2, y2)) # To rotate use image's rotate() and paste().
<ImageDraw>.rectangle((x1, y1, x2, y2)) # To rotate use Image's rotate() and paste().
<ImageDraw>.polygon((x1, y1, x2, y2, ...)) # Last point gets connected to the first.
<ImageDraw>.ellipse((x1, y1, x2, y2)) # To rotate use Image's rotate() and paste().
``` ```
* **Use `'fill=<color>'` to set the primary color.** * **Use `'fill=<color>'` to set the primary color.**
* **Use `'width=<int>'` to set the width of lines or contours.** * **Use `'width=<int>'` to set the width of lines or contours.**

22
index.html

@ -54,7 +54,7 @@
<body> <body>
<header> <header>
<aside>July 24, 2022</aside>
<aside>July 25, 2022</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header> </header>
@ -528,10 +528,10 @@ Point(x=<span class="hljs-number">1</span>, y=<span class="hljs-number">2</span>
</code></pre></div> </code></pre></div>
<div><h3 id="constructors">Constructors</h3><pre><code class="python language-python apache hljs">&lt;D&gt; = date(year, month, day)
&lt;T&gt; = time(hour=<span class="hljs-number">0</span>, minute=<span class="hljs-number">0</span>, second=<span class="hljs-number">0</span>, microsecond=<span class="hljs-number">0</span>, tzinfo=<span class="hljs-keyword">None</span>, fold=<span class="hljs-number">0</span>)
&lt;DT&gt; = datetime(year, month, day, hour=<span class="hljs-number">0</span>, minute=<span class="hljs-number">0</span>, second=<span class="hljs-number">0</span>, ...)
&lt;TD&gt; = timedelta(weeks=<span class="hljs-number">0</span>, days=<span class="hljs-number">0</span>, hours=<span class="hljs-number">0</span>, minutes=<span class="hljs-number">0</span>, seconds=<span class="hljs-number">0</span>, ...)
<div><h3 id="constructors">Constructors</h3><pre><code class="python language-python apache hljs">&lt;D&gt; = date(year, month, day) <span class="hljs-comment"># Only accepts valid dates from 1 to 9999 AD.</span>
&lt;T&gt; = time(hour=<span class="hljs-number">0</span>, minute=<span class="hljs-number">0</span>, second=<span class="hljs-number">0</span>) <span class="hljs-comment"># Also: `microsecond=0, tzinfo=None, fold=0`.</span>
&lt;DT&gt; = datetime(year, month, day, hour=<span class="hljs-number">0</span>) <span class="hljs-comment"># Also: `minute=0, second=0, microsecond=0, …`.</span>
&lt;TD&gt; = timedelta(weeks=<span class="hljs-number">0</span>, days=<span class="hljs-number">0</span>, hours=<span class="hljs-number">0</span>) <span class="hljs-comment"># Also: `minutes=0, seconds=0, microsecond=0`.</span>
</code></pre></div> </code></pre></div>
<ul> <ul>
@ -565,7 +565,7 @@ Point(x=<span class="hljs-number">1</span>, y=<span class="hljs-number">2</span>
<li><strong>ISO strings come in following forms: <code class="python hljs"><span class="hljs-string">'YYYY-MM-DD'</span></code>, <code class="python hljs"><span class="hljs-string">'HH:MM:SS.mmmuuu[±HH:MM]'</span></code>, or both separated by an arbitrary character. All parts following hours are optional.</strong></li> <li><strong>ISO strings come in following forms: <code class="python hljs"><span class="hljs-string">'YYYY-MM-DD'</span></code>, <code class="python hljs"><span class="hljs-string">'HH:MM:SS.mmmuuu[±HH:MM]'</span></code>, or both separated by an arbitrary character. All parts following hours are optional.</strong></li>
<li><strong>Python uses the Unix Epoch: <code class="python hljs"><span class="hljs-string">'1970-01-01 00:00 UTC'</span></code>, <code class="python hljs"><span class="hljs-string">'1970-01-01 01:00 CET'</span></code>, …</strong></li> <li><strong>Python uses the Unix Epoch: <code class="python hljs"><span class="hljs-string">'1970-01-01 00:00 UTC'</span></code>, <code class="python hljs"><span class="hljs-string">'1970-01-01 01:00 CET'</span></code>, …</strong></li>
</ul> </ul>
<div><h3 id="decode">Decode</h3><pre><code class="python language-python hljs">&lt;str&gt; = &lt;D/T/DT&gt;.isoformat(sep=<span class="hljs-string">'T'</span>) <span class="hljs-comment"># Also timespec='auto/hours/minutes/seconds/…'.</span>
<div><h3 id="decode">Decode</h3><pre><code class="python language-python hljs">&lt;str&gt; = &lt;D/T/DT&gt;.isoformat(sep=<span class="hljs-string">'T'</span>) <span class="hljs-comment"># Also: `timespec='auto/hours/minutes/seconds/…'`.</span>
&lt;str&gt; = &lt;D/T/DT&gt;.strftime(<span class="hljs-string">'&lt;format&gt;'</span>) <span class="hljs-comment"># Custom string representation.</span> &lt;str&gt; = &lt;D/T/DT&gt;.strftime(<span class="hljs-string">'&lt;format&gt;'</span>) <span class="hljs-comment"># Custom string representation.</span>
&lt;int&gt; = &lt;D/DT&gt;.toordinal() <span class="hljs-comment"># Days since Gregorian NYE 1, ignoring time and tz.</span> &lt;int&gt; = &lt;D/DT&gt;.toordinal() <span class="hljs-comment"># Days since Gregorian NYE 1, ignoring time and tz.</span>
&lt;float&gt; = &lt;DTn&gt;.timestamp() <span class="hljs-comment"># Seconds since the Epoch, from DTn in local tz.</span> &lt;float&gt; = &lt;DTn&gt;.timestamp() <span class="hljs-comment"># Seconds since the Epoch, from DTn in local tz.</span>
@ -2274,11 +2274,11 @@ img.convert(<span class="hljs-string">'RGB'</span>).save(<span class="hljs-strin
</code></pre></div> </code></pre></div>
<pre><code class="python language-python hljs">&lt;ImageDraw&gt;.point((x, y)) <span class="hljs-comment"># Truncates floats into ints.</span> <pre><code class="python language-python hljs">&lt;ImageDraw&gt;.point((x, y)) <span class="hljs-comment"># Truncates floats into ints.</span>
&lt;ImageDraw&gt;.line((x1, y1, x2, y2 [, ...])) <span class="hljs-comment"># To get anti-aliasing use images's resize().</span>
&lt;ImageDraw&gt;.line((x1, y1, x2, y2 [, ...])) <span class="hljs-comment"># To get anti-aliasing use Image's resize().</span>
&lt;ImageDraw&gt;.arc((x1, y1, x2, y2), deg1, deg2) <span class="hljs-comment"># Always draws in clockwise direction.</span> &lt;ImageDraw&gt;.arc((x1, y1, x2, y2), deg1, deg2) <span class="hljs-comment"># Always draws in clockwise direction.</span>
&lt;ImageDraw&gt;.rectangle((x1, y1, x2, y2)) <span class="hljs-comment"># To rotate use image's rotate() and paste().</span>
&lt;ImageDraw&gt;.polygon((x1, y1, x2, y2, ...)) <span class="hljs-comment"># Last and first point get connected.</span>
&lt;ImageDraw&gt;.ellipse((x1, y1, x2, y2)) <span class="hljs-comment"># To rotate use image's rotate() and paste().</span>
&lt;ImageDraw&gt;.rectangle((x1, y1, x2, y2)) <span class="hljs-comment"># To rotate use Image's rotate() and paste().</span>
&lt;ImageDraw&gt;.polygon((x1, y1, x2, y2, ...)) <span class="hljs-comment"># Last point gets connected to the first.</span>
&lt;ImageDraw&gt;.ellipse((x1, y1, x2, y2)) <span class="hljs-comment"># To rotate use Image's rotate() and paste().</span>
</code></pre> </code></pre>
<ul> <ul>
<li><strong>Use <code class="python hljs"><span class="hljs-string">'fill=&lt;color&gt;'</span></code> to set the primary color.</strong></li> <li><strong>Use <code class="python hljs"><span class="hljs-string">'fill=&lt;color&gt;'</span></code> to set the primary color.</strong></li>
@ -2905,7 +2905,7 @@ $ pyinstaller script.py --add-data '&lt;path&gt;:.' <span class="hljs-comment">
<footer> <footer>
<aside>July 24, 2022</aside>
<aside>July 25, 2022</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a> <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer> </footer>

Loading…
Cancel
Save