date-works 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. dt=`busybox date`
  2. # Expected format: Fri Apr 25 03:47:55 CEST 2008
  3. dt=`echo "$dt" | sed 's/^[^ ][^ ][^ ] [^ ][^ ][^ ] [ 0123][0-9] [012][0-9]:[0-5][0-9]:[0-6][0-9] [A-Z][A-Z]* [012][0-9][0-9][0-9]$/OK/'`
  4. test x"$dt" = x"OK"
  5. dt=`busybox date -d 1:2`
  6. dt=`echo "$dt" | cut -b12-19`
  7. test x"$dt" = x"01:02:00"
  8. dt=`busybox date -d 1:2:3`
  9. dt=`echo "$dt" | cut -b12-19`
  10. test x"$dt" = x"01:02:03"
  11. dt=`busybox date -d 1.2-3:4`
  12. dt=`echo "$dt" | cut -b5-19`
  13. test x"$dt" = x"Jan 2 03:04:00"
  14. dt=`busybox date -d 1.2-3:4:5`
  15. dt=`echo "$dt" | cut -b5-19`
  16. test x"$dt" = x"Jan 2 03:04:05"
  17. dt=`busybox date -d 1999.1.2-3:4`
  18. dt=`echo "$dt" | cut -b1-19`
  19. test x"$dt" = x"Sat Jan 2 03:04:00"
  20. dt=`busybox date -d 1999.1.2-3:4:5`
  21. dt=`echo "$dt" | cut -b1-19`
  22. test x"$dt" = x"Sat Jan 2 03:04:05"
  23. dt=`busybox date -d '1999-1-2 3:4:5'`
  24. dt=`echo "$dt" | cut -b1-19`
  25. test x"$dt" = x"Sat Jan 2 03:04:05"
  26. # date (GNU coreutils) 8.17 doesn't accept 01231133 either:
  27. # date: invalid date '01231133'
  28. #dt=`busybox date -d 01231133`
  29. #dt=`echo "$dt" | cut -b5-19`
  30. #test x"$dt" = x"Jan 23 11:33:00"
  31. dt=`busybox date -d 200001231133`
  32. dt=`echo "$dt" | cut -b1-19`
  33. test x"$dt" = x"Sun Jan 23 11:33:00"
  34. dt=`busybox date -d 200001231133.30`
  35. dt=`echo "$dt" | cut -b1-19`
  36. test x"$dt" = x"Sun Jan 23 11:33:30"