Interactive
Software Engineering
EiffelTime

[ISE Home] Home ] Release Notes ] Technology Papers ] Installation Notes ] About Eiffel ]


Introduction

EiffelTime is the Eiffel library that allows you to use efficiently Date and Time in your projects.

Before using EiffelTime, we suggest you to read this documentation.:

Technical Information

The library EiffelTime is built on three notions of time.

  • The absolute notion (for example, what time is it? 3:45 p.m.) is used for events.
  • It may be useful also to deal with an interval between two events (the meeting is between 3:45 p.m.and 6:00 p.m.).
  • Finally EiffelTime has the notion of duration, which is the length of an interval (the meeting will take 2:15). The notion of absolute is linked with duration by the use of an origin.

The library is located in $EIFFEL5/library/time.

You can find a detailed description of EiffelTime here.

You need EiffelTime to use EiffelStore library.

Getting Started

By default, all the files you need are installed by the installation procedure of your product. In the case, where the following library `libdatetime.a' (for Unix) or `datetime.lib' (for Windows) was not found during the C comnpilation, use the following instructions to recreate them:

  • On Windows

To install EiffelTime, you need to go to the directory $EIFFEL5\library\time\Clib and run make_msc.bat if your C compiler is Microsoft or make_bcc if Borland. 

  • On unix

Just launch finish_freezing - library in the directory $EIFFEL5\library\time\Clib.

How to configure your Ace file

In order to use EiffelTime in an Eiffel Project, you have to include in your project, the correct clusters and external files. Thus, you need to configure your Ace file.

You can get all the information about Ace files here.

To include the EiffelTime cluster you need to include in your ace file :

        eiffel_time:        "$EIFFEL5/library/time";
        format:              "$EIFFEL5/library/time/format";
        english:             "$EIFFEL5/library/time/format/english";

You also need to include the external object datetime.lib (under windows) or libdatetime.a (under unix):

           object:            "$(EIFFEL5)/library/time/spec/$(COMPILER)/lib/datetime.lib (for Windows)

           object:            "$(EIFFEL5)/library/time/spec/$(PLATFORM)/lib/libdatetime.a (for Unix)

You can check the Ace file of our example to see a working Ace file using EiffelTime.

Date-Time String conversion

The following list format conversion codes. These are all nicked direct from Excel:

Code Description
dd day - numeric
[0]dd day - numeric (padded with '0' to 2 figures.
ddd day - text (3 letters e.g "Mon, "Tue")
yyyy year - numeric (4 figures)
yy year - numeric (2 figures)
mm month - numeric
[0]mm month - numeric (padded with '0' to 2 figures)
mmm month - text (3 letters e.g "Dec", "Jan")
hh hour - numeric (24 hour clock scale by default)
[0]hh hour - numeric (padded with '0' to 2 figures)
hh12 hour - numeric (13 hour clock scale)
mi minute - numeric
[0]min minute - numeric (padded with '0' to 2 figures)
ss seconds - numeric
[0]ss seconds- numeric (padded with '0' to 2 figures)
ff<n> fractional seconds - numeric (precise to <n> figures)

 

Here are some examples of suggested STRING output.

Code Output
yy/mm/dd 99/8/18
mmm-dd-yy Aug-18-99
mm,dd,yyyy 8,18,1999
hh-mi-ss 13-06-32
hh12,mi,ss 1,06,32 PM
hh12:mi:ss.ff 1:06:32.35 PM
hh:mi:ss.ff3 13:06:32.248
[0]mm/dd/yy hh12:mi:ss.ff3 08/18/99 1:06:32.248 PM

 

A working Example

We developed an example that you can try to see how to use EiffelTime.

It is located in the directory: $EIFFEL5/examples/time/calculator.

To run this example, launch eiffel_time_calendar once you have compiled it.

Then on the prompt, you can enter :

  • h for help
  • y to add am amount of year
  • d to add an amount of days
  • s to set a new year, a new month and a new day
  • w to add an amount of week
  • m to add an amount of month
  • q to exit