From c489db32a796be2d7de7a683544c333a77d917b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?= Date: Wed, 29 Jun 2011 15:20:38 +0200 Subject: Fix undefined datetimes --- lib/kernel/src/file.erl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/kernel/src') diff --git a/lib/kernel/src/file.erl b/lib/kernel/src/file.erl index bdafcf2cfb..8f027f5a40 100644 --- a/lib/kernel/src/file.erl +++ b/lib/kernel/src/file.erl @@ -1378,10 +1378,15 @@ time_epochs_to_local(Seconds) when is_integer(Seconds) -> erlang:universaltime_to_localtime(calendar:gregorian_seconds_to_datetime(Seconds + ?SECONDS_PER_DAY * ?DAYS_FROM_0_TO_1970)). time_utc_to_epochs({_, _} = Datetime) -> - calendar:datetime_to_gregorian_seconds(Datetime) - ?SECONDS_PER_DAY * ?DAYS_FROM_0_TO_1970. + calendar:datetime_to_gregorian_seconds(Datetime) - ?SECONDS_PER_DAY * ?DAYS_FROM_0_TO_1970; +time_utc_to_epochs(undefined) -> + time_utc_to_epochs(erlang:universaltime()). + time_local_to_epochs({_, _} = Datetime) -> - calendar:datetime_to_gregorian_seconds(erlang:localtime_to_universaltime(Datetime)) - ?SECONDS_PER_DAY * ?DAYS_FROM_0_TO_1970. + calendar:datetime_to_gregorian_seconds(erlang:localtime_to_universaltime(Datetime)) - ?SECONDS_PER_DAY * ?DAYS_FROM_0_TO_1970; +time_local_to_epochs(undefined) -> + time_utc_to_epochs(erlang:universaltime()). %% file_name(FileName) -- cgit v1.2.3