*** £$π Functions (WIKI) ***
..
- HomePage
- Setup
- Basics
-
Functions
- Items
- Channels
- Listrepeat
- Multilink
- EPG
- External links
- External calls
- Regex
- Conditional DoRegex
- Python function
- Python codeblock
- Unpacker
- UnWise
- Sawlive
- Cloud Flare
- Sucuri Proxy
- Captcha
- Plugins
- JSON-RPC
- Rawpost
- Headers
- Proxy
- Cookies & Sessions
- Redirection
- Parental block
- ViewMode
- LSDirect
- LiveResolver
- ResolveUrl
- F4µ
- Inputstream
- SLProxy
- Encryption
- Examples
- FAQ?
- Developers
- Release Notes?
- ChangeLog
.
*** Doc. Kodi & PYthon ***
..
Python & Modules PY
.
.
.
.
(Video) Cache Kodi
.
.
.
Addons Kodi
.
.
.
Addons Kodi
.
.
*** GITHUB ***
..
URLresolver (J.S.) [GIT] +
.
.
.
URLresolver (elD.) [GIT] -
.
.
URLresolver (tvA.) [GIT] -
.
.
.
.
Cloudflare (external) [GIT]
.
.
.
*** Associated ***
.Pastebin Your list online
.
mediafire Upload Files
.
imgur Upload Pics
lyngsat TV logos collection
transparent .png
.
http://hola.org free? VPN
Hola.apk free? VPN App.
.
hidester- free Proxy
.
webgrabplus EPG - Eng
xmltv EPG - Fr
kazer EPG - Fr
.
.wordreference Traduction
.
mail.com (fast sign-in)
.
.
LOCAL TIME : How to subtract 1 hour from the grabbed time ?
LOCAL TIME : How to subtract 1 hour from the grabbed time ?
Originally Posted by JonnyB (in tvaddons) :
Hi,
How can I subtract 1 hour in a regex?
Example:
Some capturing group captures this time: 20:15, but in my local time is at 19:15.
Is there a way to subtract in 1 hour in this capturing group?
Thanks
------------------------------------------------------------------------------------------------------------
Answer of twogun :
Quick python lesson using your question. You want to subtract 1 hour from the grabbed time. Or from your specific example 20:15 --> 19:15
So lets say that 'time' is the data you grabbed from the website
I hope that helps
---------------------------------------------------------------------------------------
THANKS !
Hi,
How can I subtract 1 hour in a regex?
Example:
Some capturing group captures this time: 20:15, but in my local time is at 19:15.
Is there a way to subtract in 1 hour in this capturing group?
Thanks
------------------------------------------------------------------------------------------------------------
Answer of twogun :
Quick python lesson using your question. You want to subtract 1 hour from the grabbed time. Or from your specific example 20:15 --> 19:15
So lets say that 'time' is the data you grabbed from the website
- Code:
time = '20:15' # in your real code it will probaly be something like time = [makelist.param1]
localtime = int(time[:-3]) - 1
# in the above line
# int() coverts the string into an integer. This allows it to be used in math functions.
# [:-3] removes 3 characters from the end of the varible. So we get just 20 instead of the whole value 20:15
# and simple enough ' - 1 ' subtracts 1 from 20. 20 --> 19. So localtime equals 19 (an integer)
localtime = str(localtime) + time[2:]
# the above line converts localtime back to a string and combine '19' with the remaining time ':15'
# str() converts the varible to a string
# [2:] removes the first 2 characters from the varible time: 19:15 --> :15
# addition of the 2 comine the strings '19' + ':15' = '19:15'
now you can use the value how ever you need for example return it to be used by your makelist or info tags
return localtime
I hope that helps
---------------------------------------------------------------------------------------
THANKS !
Admin- Messages : 60
Date d'inscription : 2017-03-28
Update / bug fixes
When I originally wrote this I forgot to compensate for cases where the var localtime would be greater then 24 or less the 1.
Also the original code require this format HH:MM. This means that entry of H:MM would cause an error. So 1:15 would need a leading zero like this: 01:15. I've made a small change that allows the code to receive both 1:15 and 01:15 as input.
I've included a 24 hour and 12 hour version
24 hour:
12 hour:
Also the original code require this format HH:MM. This means that entry of H:MM would cause an error. So 1:15 would need a leading zero like this: 01:15. I've made a small change that allows the code to receive both 1:15 and 01:15 as input.
I've included a 24 hour and 12 hour version
24 hour:
- Code:
def GetLSProData(page_data,Cookie_Jar,m):
time = '5:15'
time = time.zfill(5) # insure the var time is 5 spaces by adding leading zero
localtime = int(time[:-3]) - 1
# if the hour is greater then 24 subtract 24 from it
if localtime > 24:
localtime -= 24
# if the hour is less then 1 add 24 to it.
if localtime < 1:
localtime += 24
localtime = str(localtime) + time[2:]
return localtime
# return localtime.zfill(5) # use this if you need leading zeros Example: 05:15pm instead of 5:15pm
12 hour:
- Code:
def GetLSProData(page_data,Cookie_Jar,m):
time = '2:15'
time = time.zfill(5) # insure the var time is 5 spaces by adding leading zero
localtime = int(time[:-3]) - 1
# if the hour is greater then 12 subtract 12
if localtime > 12:
localtime -= 12
# if the hour is less then 12 add 12 to it.
if localtime < 1:
localtime += 12
localtime = str(localtime) + time[2:]
return localtime
# return localtime.zfill(5) # use this if you need leading zeros Example: 05:15pm instead of 5:15pm
twogun- Messages : 33
Date d'inscription : 2017-04-03

» Explorin' time!
» Adventure Time: Legends of Ooo!
» No time to breath (Closed)
» Shonen Jump through the Ages
» Summertime. (Open to All)
» Adventure Time: Legends of Ooo!
» No time to breath (Closed)
» Shonen Jump through the Ages
» Summertime. (Open to All)
Permissions in this forum:
You cannot reply to topics in this forum
|
|