Reputation: 25
I'm trying to change system date, adding 8 days to current date. But unfortunately I am receiving
TypeError: SetSystemTime() takes exactly 8 arguments (1 given)
My code is:
import datetime
import win32api
now = datetime.datetime.now()
print (now)
tomorrow = now + datetime.timedelta(days = 8)
print (tomorrow)
win32api.SetSystemTime(tomorrow)
So I need to turn my 'tomorrow' valuable into a string with 8 arguments. or maybe there is a better function than SetSystemTime. Do you have any ideas?
Upvotes: 1
Views: 2073
Reputation: 341
In reference to the method win32api.SetSystemTime all the arguments must be of type integer.
import datetime
import win32api
now = datetime.datetime.now()
print (now)
tomorrow = now + datetime.timedelta(days = 8)
print (tomorrow)
year = int(tomorrow.year)
month = int(tomorrow.month)
# Return the day of the week as an integer, where Monday is 0 and Sunday is 6.
dayOfWeek = int(tomorrow.weekday())
day = int(tomorrow.day)
hour = int(tomorrow.hour)
minute = int(tomorrow.minute)
second = int(tomorrow.second)
millseconds = int((tomorrow.microsecond)/1000)
win32api.SetSystemTime(year, month , dayOfWeek , day , hour , minute , second , millseconds)
Upvotes: 2