cout << timeval

  1. Consider the struct ut_tv which we got in the exercise of Login/Logout exercise.
  2. Suppose we have a class
    class Ctimeval {
    public:
        Ctimeval(int32_t sec = 0, int32_t usec = 0) {
            tv_sec  = sec;
            tv_usec = usec;
        }
    
    private:
        int32_t tv_sec;           /* Seconds */
        int32_t tv_usec;          /* Microseconds */
    };
  3. Define a friend function operator<<() to print out the time value in the format like "Wed Mar 30 20:14:37 2022".
  4. You may test your code with the following main program:
    int main()
    {
        Ctimeval t1(1645633307, 622206);
        Ctimeval t2(time(NULL));
        cout << t1 << t2;
        return 0;
    }