time.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2010 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <grub/datetime.h>
  19. #include <time.h>
  20. grub_err_t
  21. grub_get_datetime (struct grub_datetime *datetime)
  22. {
  23. struct tm *mytm;
  24. time_t mytime;
  25. mytime = time (&mytime);
  26. mytm = gmtime (&mytime);
  27. datetime->year = mytm->tm_year + 1900;
  28. datetime->month = mytm->tm_mon + 1;
  29. datetime->day = mytm->tm_mday;
  30. datetime->hour = mytm->tm_hour;
  31. datetime->minute = mytm->tm_min;
  32. datetime->second = mytm->tm_sec;
  33. return GRUB_ERR_NONE;
  34. }
  35. grub_err_t
  36. grub_set_datetime (struct grub_datetime *datetime __attribute__ ((unused)))
  37. {
  38. return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
  39. "no clock setting routine available");
  40. }