App-Chart

 view release on metacpan or  search on metacpan

maybe/unused.pm  view on Meta::CPAN

  my ($t) = @_;
  return App::Chart::ymd_to_tdate_floor ($t->year, $t->mon, $t->mday);
}
sub wdate_to_tdate {
  my ($wdate) = @_;
  return $wdate * 5;
}


sub liststore_fill_dbi {
  my ($store, $sth) = @_;

  my $len = $store->iter_n_children(undef);
  my $iter = $store->get_iter_first;
  my @cols = (0 .. $store->get_n_columns - 1);
  while (my @data = $sth->fetchrow_array) {
    @data = List::MoreUtils::mesh (@cols, @data);
    if ($iter) {
      $store->set ($iter, @data);
      $iter = $store->iter_next ($iter);
    } else {
      $store->insert_with_values ($len++, @data);
    }
  }
  if ($iter) {
    while ($store->remove ($iter)) {
    }
  }
  $sth->finish;
}


sub liststore_truncate {
  my ($store, $n) = @_;
  my $iter = $store->iter_nth_child (undef, $pos)
    || return;
    while ($self->remove ($iter)) {
    }
}


# return $widget if it has a window, or its next windowed parent
sub _get_windowed_widget {
  my ($widget) = @_;
  while ($widget->flags & 'no-window') {
    $widget = $widget->get_parent;
    if (! $widget) { last; }
  }
  return $widget;
}


#------------------------------------------------------------------------------

sub delete_extra {
  my ($symbol, $key) = @_;
  my $dbh = App::Chart::DBI->instance;
  $dbh->do ('DELETE FROM extra WHERE symbol=? AND key=?', {}, $symbol, $key);
}

sub strftime_unixtime_local {
  my ($format, $unixtime) = @_;
  my $time = $unixtime + $App::Chart::unixtime_base;
  return App::Chart::strftime_wide ($format, localtime ($time));
}

#------------------------------------------------------------------------------

=item App::Chart::unixtime ()

Return the current time in Unix style seconds since midnight 1 Jan
1970.  This function always uses 1970 as the epoch, unlike C<time()> which
is either 1970 or 1904 depending on the platform (1904 on MacOS).

=cut

our $unixtime_base = Date::Calc::Date_to_Time (1970,1,1, 0,0,0);
sub unixtime {
  return (time () - $unixtime_base);
}




( run in 1.417 second using v1.01-cache-2.11-cpan-64ef6c95b5d )