-
Improvement
-
Resolution: Won't Do
-
Minor
-
None
-
3.1
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:
- Go to "Site administration" >"Location" > "Location settings"
- Set "Force timezone" to UTC
- Go to "Site administration" > "Users" > "Accounts" > "User profile fields"
- Select "datetime" from the drop down
- Set the start year to some year before 1970, leave everything else
- Save
- Edit a user's profile
- Set the new datetime field to 1 January 1970, save the profile
- Check their profile and notice that the field is not set