caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] OReilly exercise question
@ 2004-03-24 22:34 Vasili Galchin
  2004-03-24 22:40 ` Richard Jones
  2004-03-24 22:44 ` Zeno Lee
  0 siblings, 2 replies; 3+ messages in thread
From: Vasili Galchin @ 2004-03-24 22:34 UTC (permalink / raw)
  To: caml-list

Hello

    I am working some of the exercises in the online
OReilly book, in particular the time server in the
Distributed Computing chapter. I wrote the following
function:

(* Get time of day and send across the wire *)
let time_service ic oc =
   try
     let ts = Unix.time () in
     let (date:Unix.tm) = Unix.gmtime ts in
     let year = string_of_int (date.tm_year);
         month = string_of_int (date.tm_mon + 1);
         day = string_of_int (date.tm_mday);
         hour = string_of_int (date.tm_hour);
         minute = string_of_int (date.tm_min);
         seconds = string_of_int (date.tm_sec) in
     let r = year^month^day^hour^minute^seconds
     in output_string oc (r^"\n"); flush oc
   with _ -> Printf.eprintf "BLAH\n"; flush stdout;
xit 0;;
                                                      
                         
I get the following error from ocamlc:

File "time1.ml", line 23, characters 30-44:
Unbound record field label tm_year

I am confused because this field is in Unix.tm! ???

Regards, Vasili

__________________________________
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] OReilly exercise question
  2004-03-24 22:34 [Caml-list] OReilly exercise question Vasili Galchin
@ 2004-03-24 22:40 ` Richard Jones
  2004-03-24 22:44 ` Zeno Lee
  1 sibling, 0 replies; 3+ messages in thread
From: Richard Jones @ 2004-03-24 22:40 UTC (permalink / raw)
  To: Vasili Galchin; +Cc: caml-list

On Wed, Mar 24, 2004 at 02:34:16PM -0800, Vasili Galchin wrote:
> File "time1.ml", line 23, characters 30-44:
> Unbound record field label tm_year
> 
> I am confused because this field is in Unix.tm! ???

You need to write date.Unix.tm_year, or else

open Unix

at the start of the file.

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://www.j-london.com/
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
http://www.YouUnlimited.co.uk/ - management courses

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] OReilly exercise question
  2004-03-24 22:34 [Caml-list] OReilly exercise question Vasili Galchin
  2004-03-24 22:40 ` Richard Jones
@ 2004-03-24 22:44 ` Zeno Lee
  1 sibling, 0 replies; 3+ messages in thread
From: Zeno Lee @ 2004-03-24 22:44 UTC (permalink / raw)
  To: caml-list

The exercise is under the assumption that you've already opened the Unix
module.

try

date.Unix.tm_year

----- Original Message ----- 
From: "Vasili Galchin" <vasiliocaml@yahoo.com>
To: <caml-list@inria.fr>
Sent: Wednesday, March 24, 2004 5:34 PM
Subject: [Caml-list] OReilly exercise question


> Hello
>
>     I am working some of the exercises in the online
> OReilly book, in particular the time server in the
> Distributed Computing chapter. I wrote the following
> function:
>
> (* Get time of day and send across the wire *)
> let time_service ic oc =
>    try
>      let ts = Unix.time () in
>      let (date:Unix.tm) = Unix.gmtime ts in
>      let year = string_of_int (date.tm_year);
>          month = string_of_int (date.tm_mon + 1);
>          day = string_of_int (date.tm_mday);
>          hour = string_of_int (date.tm_hour);
>          minute = string_of_int (date.tm_min);
>          seconds = string_of_int (date.tm_sec) in
>      let r = year^month^day^hour^minute^seconds
>      in output_string oc (r^"\n"); flush oc
>    with _ -> Printf.eprintf "BLAH\n"; flush stdout;
> xit 0;;
>
>
> I get the following error from ocamlc:
>
> File "time1.ml", line 23, characters 30-44:
> Unbound record field label tm_year
>
> I am confused because this field is in Unix.tm! ???
>
> Regards, Vasili
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Finance Tax Center - File online. File on time.
> http://taxes.yahoo.com/filing.html
>
> -------------------
> To unsubscribe, mail caml-list-request@inria.fr Archives:
http://caml.inria.fr
> Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ:
http://caml.inria.fr/FAQ/
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-03-24 22:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-24 22:34 [Caml-list] OReilly exercise question Vasili Galchin
2004-03-24 22:40 ` Richard Jones
2004-03-24 22:44 ` Zeno Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).