home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / unix / question / 10636 < prev    next >
Encoding:
Internet Message Format  |  1992-09-01  |  2.5 KB

  1. From: tmilner@hprpcd.rose.hp.com (Tom Milner)
  2. Date: Mon, 31 Aug 1992 19:46:25 GMT
  3. Subject: Re: Question about date.
  4. Message-ID: <15360004@hprpcd.rose.hp.com>
  5. Organization: Performance Technology Center, Roseville
  6. Path: sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!scd.hp.com!hplextra!hpcc05!hpcuhb!hpda!hpergfg2!hprdash!hprpcd!tmilner
  7. Newsgroups: comp.unix.questions
  8. References: <1992Aug19.023924.3884@random.ccs.northeastern.edu>
  9. Lines: 58
  10.  
  11. In comp.unix.questions, simony@ccs.northeastern.edu (Simon Yeung) writes:
  12.  
  13.  
  14. |    I am writing a C shell script in which the user enter a number n
  15. |    and the script needs to find the date which is the nth day before
  16. |    the current date.  Can I do this by using some Unix commands?
  17. |
  18. |    I don't want to write a program for it, unless I have to.
  19. |
  20. |    Thanks.
  21. |
  22. |    --Simon
  23.  
  24. I believe something VERY similar was posted before...
  25.  
  26. |>
  27. |>I could sit down and take the brute-force approach and hard-code a bunch
  28. |>of cases, but I'm looking for something more simple. I've noticed that
  29. |>you can go "at now + 3 days ..." and you get the date/time back (but
  30. |>you also get an at job put in the queue...) so I was thinking that there
  31. |>may be a system call or C function that I don't know about which does
  32. |>this. So, any suggestions, please email and I'll post a summary if there
  33. |>is interest.
  34. |
  35. |You could change your location. You move 15 degrees about the earth as
  36. |you add or subtract 1 to or from your TZ. And space and time are equivalent,
  37. |no?
  38. |
  39. |Play with this script:
  40. |
  41. |        set -v
  42. |        TZ=5 date
  43. |        TZ=-19 date
  44. |        TZ=-43 date
  45. |        TZ=-163 date
  46. |
  47. |What it shows me:
  48. |
  49. |        TZ=5 date
  50. |        Fri Jul 17 20:46:58  1992
  51. |        TZ=-19 date
  52. |        Sat Jul 18 20:46:58  1992
  53. |        TZ=-43 date
  54. |        Sun Jul 19 20:46:58  1992
  55. |        TZ=-163 date
  56. |        Fri Jul 24 20:46:58  1992
  57. |--
  58. |Jean-Pierre Radley   Unix in NYC   jpr@jpr.com   jpradley!jpr   CIS: 72160,1341
  59.  
  60.                                   _____________________________________
  61.                                  /_______________  ___________________/
  62.                                                 / /
  63.                                                / /
  64.                                               / / Tom Milner (Tn: 785-5637)
  65.                                              / /  HP Performance Tech Center
  66.                                             / /   tom@hpptc16.rose.hp.com
  67.                                            /_/    __________________________
  68.                     
  69.