Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Date error and workcode need #18

Open
menesesc opened this issue Aug 27, 2020 · 2 comments
Open

Date error and workcode need #18

menesesc opened this issue Aug 27, 2020 · 2 comments

Comments

@menesesc
Copy link

  • PyZatt version: 2.0.0
  • Python version: 3.7.8
  • Operating System: macOs

Description

Hi Alexander!
I use a iFace302. When try read_att_log show me an incorrect datetime attendance: 2021-08-26 23:08:49 (now is 2020!). On terminal screen the date is correct.
One more... is possible add a workcode/incidence in this function? when download the attendance log to pendrive on the terminal, get a .dat file with this value on the last colum:

id - att datetime - terminalnumber - ? - ? - workcode
200 2020-08-26 23:08:49 7 0 1 53

What I Did

zk.read_att_log()

Thank you from Argentina

@odoo-app-dev
Copy link

hi,
The year decode has calculation problem. In /pyzatt/misc.py#L78 https://github.com/adrobinoga/pyzatt/blob/dc30714ed641388f53537319f6c0e7bd8dba544a/pyzatt/misc.py#L78 you can replace the number 2000 with 1999 as a work around.
year = int((enc_t / (3600. * 24.)) / 365) + 2000 # year

@odoo-app-dev
Copy link

There is another way to fix timestamp calculation. I found out that the pyzk package use a better timestamp calculation.
You need to remove codes in lines of 72 to 78 inside /pyzatt/misc.py

enc_t = struct.unpack('<I', enc_t_arr)[0]  # extracts the time value
secs = int(enc_t % 60)  # seconds
mins = int((enc_t / 60.) % 60)  # minutes
hour = int((enc_t / 3600.) % 24)  # hours
day = int(((enc_t / (3600. * 24.)) % 31)) + 1  # day
month = int(((enc_t / (3600. * 24. * 31.)) % 12)) + 1  # month
year = int((enc_t / (3600. * 24.)) / 365) + 2000  # year

and add the following there

  secs = enc_t % 60
  enc_t = enc_t // 60
  mins = enc_t % 60
  enc_t = enc_t // 60
  hour = enc_t % 24
  enc_t = enc_t // 24
  day = enc_t % 31 + 1
  enc_t = enc_t // 31
  month = enc_t % 12 + 1
  enc_t = enc_t // 12
  year = enc_t + 2000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants