Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-54750

Properly handle unset dates with datetime field

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 3.1
    • Administration

      All over moodle we use 0 or the empty string to mean 'not set'. In a lot of cases this doesn't matter that much as long as you are careful. With timestamps however, it does matter - since 0 is a valid timestamp. At least one are this affects is user profile fields. If you add a date field to it, and save the date 1 January 1970 (with the user's timezone set to UTC) it will save the date as 0 in the database, and it will be treated as unset. We should be using null for unset dates.

      To see an example of this:

      1. Go to "Site administration" >"Location" > "Location settings"
      2. Set "Force timezone" to UTC
      3. Go to "Site administration" > "Users" > "Accounts" > "User profile fields"
      4. Select "datetime" from the drop down
      5. Set the start year to some year before 1970, leave everything else
      6. Save
      7. Edit a user's profile
      8. Set the new datetime field to 1 January 1970, save the profile
      9. Check their profile and notice that the field is not set

            Unassigned Unassigned
            cameron1729 cameron1729
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.