Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/time.c

    r55b1efd re6165be  
    5151#include "libc/sys/time.h"
    5252
     53// TODO: documentation
    5354// TODO: test everything in this file
    5455
     
    7172#define SECS_PER_DAY (SECS_PER_HOUR * HOURS_PER_DAY)
    7273
    73 /**
    74  * Checks whether the year is a leap year.
     74/** Checks whether the year is a leap year.
    7575 *
    7676 * @param year Year since 1900 (e.g. for 1970, the value is 70).
     
    9090}
    9191
    92 /**
    93  * Returns how many days there are in the given month of the given year.
    94  * Note that year is only taken into account if month is February.
     92/** Returns how many days there are in the given month of the given year.
     93 *  Note that year is only taken into account if month is February.
    9594 *
    9695 * @param year Year since 1900 (can be negative).
     
    114113}
    115114
    116 /**
    117  * For specified year, month and day of month, returns which day of that year
    118  * it is.
     115/** For specified year, month and day of month, returns which day of that year
     116 *  it is.
    119117 *
    120118 * For example, given date 2011-01-03, the corresponding expression is:
     
    136134}
    137135
    138 /**
    139  * Integer division that rounds to negative infinity.
    140  * Used by some functions in this file.
    141  *
    142  * @param op1 Divident.
    143  * @param op2 Divisor.
    144  * @return Rounded quotient.
     136/** Integer division that rounds to negative infinity.
     137 *  Used by some functions in this file.
     138 *
     139 * @param op1
     140 * @param op2
     141 * @return
    145142 */
    146143static time_t _floor_div(time_t op1, time_t op2)
     
    153150}
    154151
    155 /**
    156  * Modulo that rounds to negative infinity.
    157  * Used by some functions in this file.
    158  *
    159  * @param op1 Divident.
    160  * @param op2 Divisor.
    161  * @return Remainder.
     152/** Modulo that rounds to negative infinity.
     153 *  Used by some functions in this file.
     154 *
     155 * @param op1
     156 * @param op2
     157 * @return
    162158 */
    163159static time_t _floor_mod(time_t op1, time_t op2)
     
    178174}
    179175
    180 /**
    181  * Number of days since the Epoch.
    182  * Epoch is 1970-01-01, which is also equal to day 0.
     176/** Number of days since the Epoch.
     177 *  Epoch is 1970-01-01, which is also equal to day 0.
    183178 *
    184179 * @param year Year (year 1900 = 0, may be negative).
     
    194189}
    195190
    196 /**
    197  * Seconds since the Epoch. see also _days_since_epoch().
     191/** Seconds since the Epoch. see also _days_since_epoch().
    198192 *
    199193 * @param tm Normalized broken-down time.
     
    207201}
    208202
    209 /**
    210  * Which day of week the specified date is.
     203/** Which day of week the specified date is.
    211204 *
    212205 * @param year Year (year 1900 = 0).
     
    221214}
    222215
    223 /**
    224  * Normalizes the broken-down time and optionally adds specified amount of
    225  * seconds.
     216/** Normalizes the broken-down time and optionally adds specified amount of
     217 *  seconds.
    226218 *
    227219 * @param tm Broken-down time to normalize.
     
    305297}
    306298
    307 /**
    308  * Which day the week-based year starts on, relative to the first calendar day.
    309  * E.g. if the year starts on December 31st, the return value is -1.
     299/** Which day the week-based year starts on, relative to the first calendar day.
     300 *  E.g. if the year starts on December 31st, the return value is -1.
    310301 *
    311302 * @param Year since 1900.
     
    318309}
    319310
    320 /**
    321  * Returns week-based year of the specified time.
     311/** Returns week-based year of the specified time.
    322312 *
    323313 * @param tm Normalized broken-down time.
     
    339329}
    340330
    341 /**
    342  * Week number of the year, assuming weeks start on sunday.
    343  * The first Sunday of January is the first day of week 1;
    344  * days in the new year before this are in week 0.
     331/** Week number of the year, assuming weeks start on sunday.
     332 *  The first Sunday of January is the first day of week 1;
     333 *  days in the new year before this are in week 0.
    345334 *
    346335 * @param tm Normalized broken-down time.
     
    353342}
    354343
    355 /**
    356  * Week number of the year, assuming weeks start on monday.
    357  * If the week containing January 1st has four or more days in the new year,
    358  * then it is considered week 1. Otherwise, it is the last week of the previous
    359  * year, and the next week is week 1. Both January 4th and the first Thursday
    360  * of January are always in week 1.
     344/** Week number of the year, assuming weeks start on monday.
     345 *  If the week containing January 1st has four or more days in the new year,
     346 *  then it is considered week 1. Otherwise, it is the last week of the previous
     347 *  year, and the next week is week 1. Both January 4th and the first Thursday
     348 *  of January are always in week 1.
    361349 *
    362350 * @param tm Normalized broken-down time.
     
    378366}
    379367
    380 /**
    381  * Week number of the year, assuming weeks start on monday.
    382  * The first Monday of January is the first day of week 1;
    383  * days in the new year before this are in week 0.
     368/** Week number of the year, assuming weeks start on monday.
     369 *  The first Monday of January is the first day of week 1;
     370 *  days in the new year before this are in week 0.
    384371 *
    385372 * @param tm Normalized broken-down time.
     
    398385char *posix_tzname[2];
    399386
    400 /**
    401  * Set timezone conversion information.
     387/** Set timezone conversion information.
     388 *
    402389 */
    403390void posix_tzset(void)
     
    410397}
    411398
    412 /**
    413  * Calculate the difference between two times, in seconds.
    414  *
    415  * @param time1 First time.
    416  * @param time0 Second time.
     399/** Calculate the difference between two times, in seconds.
     400 *
     401 * @param time1
     402 * @param time0
    417403 * @return Time in seconds.
    418404 */
     
    422408}
    423409
    424 /**
    425  * This function first normalizes the provided broken-down time
    426  * (moves all values to their proper bounds) and then tries to
    427  * calculate the appropriate time_t representation.
     410/** This function first normalizes the provided broken-down time
     411 *  (moves all values to their proper bounds) and then tries to
     412 *  calculate the appropriate time_t representation.
    428413 *
    429414 * @param tm Broken-down time.
    430  * @return time_t representation of the time, undefined value on overflow.
     415 * @return time_t representation of the time, undefined value on overflow
    431416 */
    432417time_t posix_mktime(struct posix_tm *tm)
     
    439424}
    440425
    441 /**
    442  * Converts a time value to a broken-down UTC time.
     426/** Converts a time value to a broken-down UTC time.
    443427 *
    444428 * @param timer Time to convert.
     
    453437}
    454438
    455 /**
    456  * Converts a time value to a broken-down UTC time.
     439/** Converts a time value to a broken-down UTC time.
    457440 *
    458441 * @param timer Time to convert.
     
    482465}
    483466
    484 /**
    485  * Converts a time value to a broken-down local time.
     467/** Converts a time value to a broken-down local time.
    486468 *
    487469 * @param timer Time to convert.
     
    494476}
    495477
    496 /**
    497  * Converts a time value to a broken-down local time.
     478/** Converts a time value to a broken-down local time.
    498479 *
    499480 * @param timer Time to convert.
     
    509490}
    510491
    511 /**
    512  * Converts broken-down time to a string in format
    513  * "Sun Jan 1 00:00:00 1970\n". (Obsolete)
     492/** Converts broken-down time to a string in format
     493 *  "Sun Jan 1 00:00:00 1970\n". (Obsolete)
    514494 *
    515495 * @param timeptr Broken-down time structure.
     
    522502}
    523503
    524 /**
    525  * Converts broken-down time to a string in format
    526  * "Sun Jan 1 00:00:00 1970\n". (Obsolete)
     504/** Converts broken-down time to a string in format
     505 *  "Sun Jan 1 00:00:00 1970\n". (Obsolete)
    527506 *
    528507 * @param timeptr Broken-down time structure.
     
    555534}
    556535
    557 /**
    558  * Equivalent to asctime(localtime(clock)).
     536/** Equivalent to asctime(localtime(clock)).
    559537 *
    560538 * @param timer Time to convert.
     
    570548}
    571549
    572 /**
    573  * Reentrant variant of ctime().
     550/** Reentrant variant of ctime().
    574551 *
    575552 * @param timer Time to convert.
     
    587564}
    588565
    589 /**
    590  * Convert time and date to a string, based on a specified format and
    591  * current locale.
     566/** Convert time and date to a string, based on a specified format and
     567 *  current locale.
    592568 *
    593569 * @param s Buffer to write string to.
     
    779755}
    780756
    781 /**
    782  * Get clock resolution. Only CLOCK_REALTIME is supported.
     757/** Get clock resolution. Only CLOCK_REALTIME is supported.
    783758 *
    784759 * @param clock_id Clock ID.
     
    801776}
    802777
    803 /**
    804  * Get time. Only CLOCK_REALTIME is supported.
     778/** Get time. Only CLOCK_REALTIME is supported.
    805779 *
    806780 * @param clock_id ID of the clock to query.
    807781 * @param tp Pointer to the variable where the time is to be written.
    808  * @return 0 on success, -1 with errno on failure.
     782 * @return
    809783 */
    810784int posix_clock_gettime(posix_clockid_t clock_id, struct posix_timespec *tp)
     
    826800}
    827801
    828 /**
    829  * Set time on a specified clock. As HelenOS doesn't support this yet,
    830  * this function always fails.
     802/** Set time on a specified clock. As HelenOS doesn't support this yet,
     803 *  this function always fails.
    831804 *
    832805 * @param clock_id ID of the clock to set.
     
    852825}
    853826
    854 /**
    855  * Sleep on a specified clock.
     827/** Sleep on a specified clock.
    856828 *
    857829 * @param clock_id ID of the clock to sleep on (only CLOCK_REALTIME supported).
     
    883855}
    884856
    885 /**
    886  * Get CPU time used since the process invocation.
     857/** Get CPU time used since the process invocation.
    887858 *
    888859 * @return Consumed CPU cycles by this process or -1 if not available.
Note: See TracChangeset for help on using the changeset viewer.