time.h File Reference

Time-related functions and macros. More...

#include "asterisk/inline_api.h"

Include dependency graph for time.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void ast_format_duration_hh_mm_ss (int duration, char *buf, size_t length)
 Formats a duration into HH:MM:SS.
int ast_remaining_ms (struct timeval start, int max_ms)
 Calculate remaining milliseconds given a starting timestamp and upper bound.
struct timeval ast_samp2tv (unsigned int _nsamp, unsigned int _rate)
 Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to timevals, or even milliseconds to timevals in the form ast_samp2tv(milliseconds, 1000).
struct timeval ast_tv (ast_time_t sec, ast_suseconds_t usec)
 Returns a timeval from sec, usec.
struct timeval ast_tvadd (struct timeval a, struct timeval b)
 Returns the sum of two timevals a + b.
int ast_tvcmp (struct timeval _a, struct timeval _b)
 Compres two struct timeval instances returning -1, 0, 1 if the first arg is smaller, equal or greater to the second.
int64_t ast_tvdiff_ms (struct timeval end, struct timeval start)
 Computes the difference (in milliseconds) between two struct timeval instances.
int64_t ast_tvdiff_sec (struct timeval end, struct timeval start)
 Computes the difference (in seconds) between two struct timeval instances.
int64_t ast_tvdiff_us (struct timeval end, struct timeval start)
 Computes the difference (in microseconds) between two struct timeval instances.
int ast_tveq (struct timeval _a, struct timeval _b)
 Returns true if the two struct timeval arguments are equal.
struct timeval ast_tvnow (void)
 Returns current timeval. Meant to replace calls to gettimeofday().
struct timeval ast_tvsub (struct timeval a, struct timeval b)
 Returns the difference of two timevals a - b.
int ast_tvzero (const struct timeval t)
 Returns true if the argument is 0,0.
typedef typeof (tv.tv_sec) ast_time_t

Variables

struct timeval tv


Detailed Description

Time-related functions and macros.

Definition in file time.h.


Function Documentation

void ast_format_duration_hh_mm_ss ( int  duration,
char *  buf,
size_t  length 
)

Formats a duration into HH:MM:SS.

Since:
12
Parameters:
duration The time (in seconds) to format
buf A buffer to hold the formatted string'
length The size of the buffer

Definition at line 1770 of file main/utils.c.

Referenced by show_chanstats_cb().

01771 {
01772    int durh, durm, durs;
01773    durh = duration / 3600;
01774    durm = (duration % 3600) / 60;
01775    durs = duration % 60;
01776    snprintf(buf, length, "%02d:%02d:%02d", durh, durm, durs);
01777 }

int ast_remaining_ms ( struct timeval  start,
int  max_ms 
)

Calculate remaining milliseconds given a starting timestamp and upper bound.

If the upper bound is negative, then this indicates that there is no upper bound on the amount of time to wait. This will result in a negative return.

Parameters:
start When timing started being calculated
max_ms The maximum number of milliseconds to wait from start. May be negative.
Returns:
The number of milliseconds left to wait for. May be negative.

Definition at line 1754 of file main/utils.c.

References ast_tvdiff_ms(), and ast_tvnow().

Referenced by __analog_ss_thread(), __ast_answer(), __ast_request_and_dial(), analog_ss_thread(), ast_recvtext(), ast_safe_sleep_conditional(), ast_waitfordigit_full(), disable_t38(), find_cache(), generic_fax_exec(), parking_set_duration(), receivefax_t38_init(), record_exec(), sendfax_t38_init(), tcptls_stream_read(), tcptls_stream_write(), wait_for_answer(), and waitforring_exec().

01755 {
01756    int ms;
01757 
01758    if (max_ms < 0) {
01759       ms = max_ms;
01760    } else {
01761       ms = max_ms - ast_tvdiff_ms(ast_tvnow(), start);
01762       if (ms < 0) {
01763          ms = 0;
01764       }
01765    }
01766 
01767    return ms;
01768 }

struct timeval ast_samp2tv ( unsigned int  _nsamp,
unsigned int  _rate 
) [read]

struct timeval ast_tv ( ast_time_t  sec,
ast_suseconds_t  usec 
) [read]

struct timeval ast_tvadd ( struct timeval  a,
struct timeval  b 
) [read]

int ast_tvcmp ( struct timeval  _a,
struct timeval  _b 
) [inline]

Compres two struct timeval instances returning -1, 0, 1 if the first arg is smaller, equal or greater to the second.

Definition at line 120 of file time.h.

Referenced by ast_pickup_find_by_group(), ast_sched_runq(), ast_waitfor_nandfds(), create_dtmf_frame(), extensionstate_update(), find_cache(), find_ringing_channel(), get_device_state_causing_channels(), interval_hook_time_cmp(), sched_settime(), and sched_time_cmp().

00127 {

int64_t ast_tvdiff_ms ( struct timeval  end,
struct timeval  start 
) [inline]

Computes the difference (in milliseconds) between two struct timeval instances.

Parameters:
end end of the time period
start beginning of the time period
Returns:
the difference in milliseconds

Definition at line 90 of file time.h.

Referenced by __analog_handle_event(), __ast_read(), __get_from_jb(), acf_jabberreceive_read(), action_coreshowchannels(), ast_audiohook_write_frame(), ast_careful_fwrite(), ast_carefulwrite(), ast_cdr_format_var(), ast_channel_cmpwhentohangup_tv(), ast_channel_end_dtmf(), ast_channel_get_duration(), ast_channel_get_up_time(), ast_check_hangup(), ast_get_enum(), ast_poll2(), ast_remaining_ms(), ast_rtp_read(), ast_sched_wait(), ast_waitfor_nandfds(), audiohook_read_frame_both(), background_detect_exec(), bridge_agent_hold_heartbeat(), bridge_channel_feature_timeout(), bridge_channel_handle_feature_timeout(), bridge_channel_handle_interval(), bridge_channel_next_interval(), bridge_channel_settle_owed_events(), calc_rxstamp(), calc_timestamp(), calc_txpeerstamp(), calc_txstamp(), cdr_object_get_billsec(), cdr_object_get_duration(), check_timer(), cli_show_channel(), cli_show_channels(), conf_run(), contact_expiration_observer_created(), contact_expiration_observer_updated(), contact_expiration_setup(), contact_expire(), dahdi_handle_event(), dahdi_read(), destroy_trans(), disa_exec(), dundi_do_lookup(), dundi_do_precache(), dundi_lookup_internal(), dundi_precache_internal(), dundi_query_eid_internal(), fax_detect_framehook(), fax_gateway_framehook(), fix_peerts(), get_now(), handle_chanlist(), handle_cli_file_convert(), handle_cli_performance_test(), handle_keepalive_message(), handle_recordfile(), handle_response_peerpoke(), handle_timeout_trip(), hook_callback(), hook_event_cb(), limits_interval_playback(), measurenoise(), misdn_overlap_dial_task(), misdn_read(), monmp3thread(), mp3_exec(), NBScat_exec(), process_dtmf_rfc2833(), purge_old_fn(), purge_old_messages(), receive_ademco_event(), receive_dtmf_digits(), registrar_add_contact(), retrans_pkt(), setformat(), should_skip_dtmf(), sla_calc_station_timeouts(), sla_calc_trunk_timeouts(), sla_check_failed_station(), sla_check_station_delay(), smdi_message_wait(), speech_background(), subscription_persistence_recreate(), talk_detect_audiohook_cb(), testloop(), timeout_read(), timing_test(), update_jbsched(), updates(), wait_for_output(), and waituntil_exec().

00097 {

int64_t ast_tvdiff_sec ( struct timeval  end,
struct timeval  start 
) [inline]

Computes the difference (in seconds) between two struct timeval instances.

Parameters:
end the end of the time period
start the beginning of the time period
Returns:
the difference in seconds

Definition at line 56 of file time.h.

Referenced by _ast_odbc_request_obj2(), acf_jabberreceive_read(), delete_old_messages(), generate_status(), purge_events(), transmit_audio(), and transmit_t38().

00066 {

int64_t ast_tvdiff_us ( struct timeval  end,
struct timeval  start 
) [inline]

Computes the difference (in microseconds) between two struct timeval instances.

Parameters:
end the end of the time period
start the beginning of the time period
Returns:
the difference in microseconds

Definition at line 70 of file time.h.

Referenced by ast_merge_contexts_and_delete(), execute_cb(), handle_cli_sched_bench(), is_timed_out(), mysql_log(), odbc_log(), pgsql_log(), sqlite_log(), tds_log(), transmit_t38(), and update_contact_status().

00080 {

int ast_tveq ( struct timeval  _a,
struct timeval  _b 
) [inline]

Returns true if the two struct timeval arguments are equal.

Definition at line 130 of file time.h.

References NULL.

Referenced by ast_translate().

00137 {

struct timeval ast_tvnow ( void   )  [read]

Returns current timeval. Meant to replace calls to gettimeofday().

Definition at line 142 of file time.h.

Referenced by __analog_handle_event(), __analog_ss_thread(), __ast_answer(), __ast_channel_alloc_ap(), __ast_manager_event_multichan(), __ast_read(), __ast_request_and_dial(), __ast_rwlock_timedrdlock(), __ast_rwlock_timedwrlock(), __dahdi_exception(), __get_from_jb(), __sip_reliable_xmit(), _ast_odbc_request_obj2(), _sip_tcp_helper_thread(), acf_jabberreceive_read(), acf_strftime(), action_coreshowchannels(), action_ping(), agent_alert(), agent_login_exec(), agent_run(), alarmreceiver_exec(), alloc_security_event_json_object(), analog_call(), analog_ss_thread(), append_event(), ast_audiohook_trigger_wait(), ast_audiohook_write_frame(), ast_bridge_channel_feature_digit(), ast_bridge_interval_hook(), ast_careful_fwrite(), ast_carefulwrite(), ast_cdr_fork(), ast_cdr_format_var(), ast_cdr_reset(), ast_cel_create_event(), ast_channel_cmpwhentohangup_tv(), ast_channel_end_dtmf(), ast_channel_get_duration(), ast_channel_get_up_time(), ast_channel_setwhentohangup_tv(), ast_check_hangup(), ast_check_timing(), ast_get_enum(), ast_http_send(), ast_log_full(), ast_merge_contexts_and_delete(), ast_module_reload(), ast_odbc_prepare_and_execute(), ast_odbc_smart_execute(), ast_poll2(), ast_queue_log(), ast_raw_answer(), ast_recvtext(), ast_remaining_ms(), ast_rtp_destroy(), ast_rtp_dtmf_begin(), ast_rtp_dtmf_end_with_duration(), ast_rtp_sendcng(), ast_safe_sleep_conditional(), ast_say_date_with_format_da(), ast_say_date_with_format_de(), ast_say_date_with_format_en(), ast_say_date_with_format_es(), ast_say_date_with_format_fr(), ast_say_date_with_format_gr(), ast_say_date_with_format_he(), ast_say_date_with_format_it(), ast_say_date_with_format_nl(), ast_say_date_with_format_pl(), ast_say_date_with_format_pt(), ast_say_date_with_format_th(), ast_say_date_with_format_vi(), ast_say_date_with_format_zh(), ast_say_datetime_from_now_en(), ast_say_datetime_from_now_fr(), ast_say_datetime_from_now_he(), ast_say_datetime_from_now_ka(), ast_say_datetime_from_now_pt(), ast_sched_dump(), ast_sched_runq(), ast_sched_wait(), ast_sched_when(), ast_senddigit_begin(), AST_TEST_DEFINE(), ast_translate(), ast_waitfor_nandfds(), ast_waitfordigit_full(), audiohook_read_frame_both(), authenticate(), background_detect_exec(), bridge_agent_hold_heartbeat(), bridge_builtin_set_limits(), bridge_channel_feature_timeout(), bridge_channel_handle_feature_timeout(), bridge_channel_handle_interval(), bridge_channel_next_interval(), bridge_channel_settle_owed_events(), bridge_channel_write_frame(), bridge_sync_wait(), build_device(), calc_rxstamp(), calc_timestamp(), calc_txstamp(), caldav_load_calendar(), calendar_busy_callback(), calendar_devstate_change(), calendar_write_exec(), callerid_genmsg(), canary_thread(), cb_events(), cdr_object_check_party_a_answer(), cdr_object_finalize(), cdr_object_get_billsec(), cdr_object_get_duration(), check_timer(), cleanup(), cli_prompt(), cli_show_channel(), cli_show_channels(), cli_tps_ping(), conf_run(), consumer_should_stay(), consumer_wait_for(), consumer_wait_for_completion(), contact_expiration_observer_created(), contact_expiration_observer_updated(), contact_expiration_setup(), contact_expire(), create_dtmf_frame(), create_transaction(), dahdi_handle_event(), dahdi_read(), debug_check_frame_for_silence(), delete_old_messages(), destroy_trans(), dial_exec_full(), disa_exec(), disable_t38(), do_cdr(), do_refresh(), do_timing(), dundi_do_lookup(), dundi_do_precache(), dundi_lookup_internal(), dundi_precache_internal(), dundi_query_eid_internal(), evt_gen_auth_method_not_allowed(), evt_gen_chal_resp_failed(), evt_gen_chal_sent(), evt_gen_failed_acl(), evt_gen_inval_acct_id(), evt_gen_inval_password(), evt_gen_inval_transport(), evt_gen_load_avg(), evt_gen_mem_limit(), evt_gen_req_bad_format(), evt_gen_req_no_support(), evt_gen_req_not_allowed(), evt_gen_session_limit(), evt_gen_successful_auth(), evt_gen_unexpected_addr(), ewscal_load_calendar(), exchangecal_load_calendar(), fax_detect_framehook(), fax_detect_new(), fax_gateway_detect_t38(), fax_gateway_framehook(), fax_gateway_request_t38(), find_cache(), find_conf_realtime(), find_tpeer(), fix_peerts(), generate_parked_user(), generate_status(), generic_fax_exec(), get_date(), get_ewscal_ids_for(), get_lock(), get_tick_count(), handle_chanlist(), handle_cli_file_convert(), handle_cli_iax2_show_cache(), handle_cli_performance_test(), handle_cli_sched_bench(), handle_cli_test_locales(), handle_keepalive_message(), handle_recordfile(), handle_response_peerpoke(), handle_response_register(), handle_showcalls(), handle_showchan(), handle_showuptime(), handle_timeout_trip(), handler_wait_for_message(), has_complex_started(), hook_callback(), hook_event_cb(), iax2_datetime(), iax2_process_thread(), iax2_trunk_queue(), ical_load_calendar(), init_start_time(), is_timed_out(), jb_framedata_init(), leave_voicemail(), limits_interval_playback(), load_config(), logging_on_tx_msg(), main(), make_deadline(), make_logchannel(), mb_poll_thread(), measurenoise(), meetme_stasis_generate_msg(), message_received_handler(), mgcp_postrequest(), mid_test_sync(), misdn_overlap_dial_task(), misdn_read(), monitor_dial(), monmp3thread(), mp3_exec(), mwi_monitor_handler(), mysql_log(), NBScat_exec(), odbc_obj_connect(), parked_call_payload_from_parked_user(), pbx_builtin_gotoiftime(), phone_call(), play_message_datetime(), process_text_line(), pthread_timer_set_rate(), purge_events(), purge_old_messages(), qualify_peer(), queue_ringing_trunk(), realtime_common(), receive_ademco_event(), receive_dtmf_digits(), receivefax_t38_init(), record_exec(), registrar_add_contact(), retrans_pkt(), rt_extend_conf(), rtcp_message_handler(), rx_task(), sched_run(), sched_settime(), schedule_calendar_event(), send_date_time(), send_date_time2(), send_date_time3(), send_device_state(), send_start_msg_snapshots(), sendfax_t38_init(), sendmail(), session_do(), set_header(), setformat(), should_skip_dtmf(), shutdown_waitfor_completion(), shutdown_waitfor_start(), single_state_init_function(), sip_poke_peer(), skinny_session(), sla_calc_station_timeouts(), sla_calc_trunk_timeouts(), sla_check_failed_station(), sla_check_station_delay(), sla_create_failed_station(), sla_create_ringing_station(), sla_process_timers(), smdi_message_wait(), smdi_read(), sms_handleincoming(), sms_handleincoming_proto2(), sms_readfile(), sms_writefile(), socket_process_meta(), speech_background(), stasis_end_to_json(), stasis_message_create_full(), store_config(), subscription_persistence_recreate(), subscription_persistence_update(), talk_detect_audiohook_cb(), task_wait(), tcptls_stream_read(), tcptls_stream_write(), testloop(), timeout_read(), timeout_write(), timing_read(), timing_test(), transmit_audio(), transmit_definetimedate(), transmit_notify_request_with_callerid(), transmit_t38(), unload_module(), update_caldav(), update_contact_status(), update_exchangecal(), update_jbsched(), user_event_wait_for_events(), verify_mock_cdr_record(), vmu_tm(), wait_for_answer(), wait_for_completion(), wait_for_complex_completion(), wait_for_complex_start(), wait_for_empty_notice(), wait_for_output(), wait_for_stimulus(), wait_for_task_pushed(), wait_until_thread_state(), waitforring_exec(), waituntil_exec(), worker_idle(), write_history(), write_metadata(), and xmpp_pak_message().

00156 :MM:SS

struct timeval ast_tvsub ( struct timeval  a,
struct timeval  b 
) [read]

Returns the difference of two timevals a - b.

Definition at line 2569 of file extconf.c.

References a, b, ONE_MILLION, and tvfix().

Referenced by ast_poll2(), ast_sched_dump(), AST_TEST_DEFINE(), ast_translate(), ast_waitfor_nandfds(), calc_rxstamp(), calc_timestamp(), cli_tps_ping(), conf_run(), debug_check_frame_for_silence(), handle_showcalls(), and handle_showuptime().

02570 {
02571    /* consistency checks to guarantee usec in 0..999999 */
02572    a = tvfix(a);
02573    b = tvfix(b);
02574    a.tv_sec -= b.tv_sec;
02575    a.tv_usec -= b.tv_usec;
02576    if (a.tv_usec < 0) {
02577       a.tv_sec-- ;
02578       a.tv_usec += ONE_MILLION;
02579    }
02580    return a;
02581 }

int ast_tvzero ( const struct timeval  t  )  [inline]

typedef typeof ( tv.  tv_sec  ) 


Variable Documentation

struct timeval tv


Generated on Thu Apr 16 06:34:32 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6