Re: Standard library - date and time

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jeremy Cowgar wrote:
> 1. Let's not change the existing date() and time() functions. We are adding
> to the standard library, not redesigning it. 
> 
> 2. We should prefix some things. For instance, the map functions deal with
> maps
> and task function deal with tasks.
> 
> I have found three email addresses for Carl (author of datetime) and have sent
> an email asking if it could be included in Euphoria. datetime has a copyright
> statement and no released license.

Hi,

I committed the prototype of datetime functions by adhering to the points
above.
We defined a new type: datetime (the implementation is not done, waiting
for the permission as mentioned above).
The prefix is datetime_ (should it be date_ ? but since the type name
is datetime, will it confuse users?)

To maintain compatibility with built-in date(), the datetime object
can be created using datetime_from_date(). 
The now function is named datetime_now().

Here are the function prototypes (some C-style for clarity).
Please give suggestions etc.

-- Date and Time functions
-- 2008
-- note 2008-04-23: ONLY CONTAINS FUNCTION PROTOTYPES
-- No timezone offset.

-- global type datetime(object o)

-- datetime datetime_new(int year, int month, int date, int hour, int minute,
int second)
-- Creates the datetime object for the specified parameters

-- int datetime_compare(datetime dt1, datetime dt2)
-- Compare the receiver to the specified Date to determine the relative
ordering.
-- returns -1 or 0 or 1

-- datetime datetime_from_date(object date)
-- Converts the built-in date() format to datetime format

-- datetime datetime_now()
-- Returns the datetime object for now. No timezones!

-- int 	datetime_get_hour(datetime dt)
-- Answers the gregorian calendar hour of the day. 

-- int 	datetime_get_minute(datetime dt)
-- Answers the gregorian calendar minute of the hour. 

-- int 	datetime_get_second(datetime dt)
-- Answers the gregorian calendar second of the minute. 

-- int 	datetime_get_year()
-- Answers the gregorian calendar year since 1900. 

-- int 	datetime_get_month(datetime dt)
-- Answers the gregorian calendar month. 

-- int datetime_get_date(datetime dt)
-- Answers the gregorian calendar day of the month. 

-- int 	datetime_get_day(datetime dt)
-- Answers the gregorian calendar day of the week. 

-- datetime  datetime_set_hour(integer dt)
-- Sets the gregorian calendar hour of the day. 
global function datetime_set_hour(integer dt)

-- datetime  datetime_set_minute(int dt)
-- Sets the gregorian calendar minute of the hour. 

-- datetime  datetime_set_second(int dt)
-- Sets the gregorian calendar second of the minute. 

-- datetime  datetime_set_year()
-- Sets the gregorian calendar year since 1900. 

-- datetime  datetime_set_month(datetime dt)
-- Sets the gregorian calendar month. 

-- datetime datetime_set_date(datetime dt)
-- Sets the gregorian calendar day of the month. 

-- datetime datetime_parse(ustring string)
-- parse the string and returns the datetime

-- ustring datetime_format(ustring format)
-- format the date according to the format string
-- format string some taken from date(1)
--  %%     a literal %
--  %a     locale's abbreviated weekday name (e.g., Sun)
--  %A     locale's full weekday name (e.g., Sunday)
--  %b     locale's abbreviated month name (e.g., Jan)
--  %B     locale's full month name (e.g., January)
--  %C     century; like %Y, except omit last two digits (e.g., 21)
--  %d     day of month (e.g, 01)
--  %g     last two digits of year of ISO week number (see %G)
--  %H     hour (00..23)
--  %I     hour (01..12)
--  %j     day of year (001..366)
--  %k     hour ( 0..23)
--  %l     hour ( 1..12)
--  %m     month (01..12)
--  %M     minute (00..59)
--  %p     locale's equivalent of either AM or PM; blank if not known
--  %P     like %p, but lower case
--  %s     seconds since 1970-01-01 00:00:00 UTC
--  %S     second (00..60)
--  %u     day of week (1..7); 1 is Monday
--  %w     day of week (0..6); 0 is Sunday
--  %y     last two digits of year (00..99)
--  %Y     year

-- atom datetime_to_unix(datetime dt)
-- returns the number of seconds since 1970-1-1 0:0 (no timezone!)

-- datetime datetime_add_second(datetime dt, atom seconds)
-- adds the date with specified number of seconds

-- datetime datetime_add_day(datetime dt, atom days)
-- adds the date with specified number of days

-- atom datetime_diff_second(datetime dt1, datetime dt2)
-- returns the number of seconds between two datetimes

-- atom datetime_diff_day(datetime dt1, datetime dt2)
-- returns the number of days between two datetimes

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu