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

Fix/setting unix time stamp to input tap detection #899

Merged
merged 2 commits into from
Nov 18, 2024

Conversation

felipeMetaLab
Copy link
Contributor

📝 Description

🔗 Jira Ticket M2-7967

This pull request fixes an issue with how timestamps were being calculated using CACurrentMediaTime() in our native Swift component. Initially, CACurrentMediaTime() was used directly, but it was being misinterpreted as a UNIX timestamp, leading to incorrect results. This change adds a method to generate a correct UNIX timestamps.

CACurrentMediaTime() returns the elapsed time since the system's boot (in seconds), but it does not correspond to an absolute timestamp or the UNIX epoch (1970-01-01). Using it directly caused several issues such as incorrect date format.

To address this, I added a new method called bootTime. This method calculates the system's boot time offset by subtracting the CACurrentMediaTime() from the current time (Date().timeIntervalSince1970). This ensures that we can correctly adjust the time provided by CACurrentMediaTime() and treat it as an accurate UNIX timestamp.

The new bootTime value is used to adjust the CACurrentMediaTime() result, so that the calculated timestamps are now consistent with actual calendar dates and times.

📸 Screenshots

Comparison:
Screenshot 2024-11-15 at 4 18 11 PM

sample of new unix date:
Screenshot 2024-11-15 at 4 14 44 PM

Screenshot 2024-11-15 at 4 21 01 PM

Code hight lights:
Screenshot 2024-11-15 at 4 28 07 PM
Screenshot 2024-11-15 at 4 29 32 PM

🪤 Peer Testing

  • lauch the app
  • Create a Serial Reaction Time performance task
  • Set time between screens to more than 1000ms (Show each stimulus for)
  • Run task on an iOS device
  • When the button is presented, wait at least 500ms and then attempt to tap the button
    Before:
    Input will be ignored the longer you wait to tap the button (disabled state)
    Expected:
    now you will be able to click all the times.
  • go to admin app, and select the applet that responding for your task and download the CSV file, and check if the timestamp is correct.

Copy link

@ramirlm ramirlm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me

@felipeMetaLab felipeMetaLab merged commit 8438d4d into dev Nov 18, 2024
5 checks passed
ChaconC pushed a commit that referenced this pull request Nov 19, 2024
* feature/adding unix time

* fix creating boot time to fix the timestamp result

---------

Co-authored-by: Felipe Imperio <[email protected]>
ChaconC pushed a commit that referenced this pull request Dec 6, 2024
* feature/adding unix time

* fix creating boot time to fix the timestamp result

---------

Co-authored-by: Felipe Imperio <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants