小编mch*_*mch的帖子

PHP中日出和日落时间的计算

注意:这是我的好奇心练习,已有解决此问题的功能/代码(另请参见注释)

可以在此处找到用于计算日出和日落时间的算法,以及在1 in Tcl2 in的实现javascript

我正在尝试将算法转换为PHP,但是这有点麻烦,并且花费太多时间。到目前为止,这是我的结果:

<?php
$sunrise = sunriseSunsetTimeTest(9, 4, 2015, 46.929512, 7.565272);
$sunset = sunriseSunsetTimeTest(9, 4, 20, 46.929512, 7.565272, 'sunset');

echo $sunrise . '/' . $sunset;
/* output is: 12.314714533758/12.612340511889 (?) */

function sunriseSunsetTimeTest($day, $month, $year, $latitude, $longitude,
                                    $which='sunrise', $localTimeOffset=1, $zenith=96){
    /*
     * Output:
     * sunrise or sunset time depending on parameter $which
     *
     * Input:
     * (int) day
     * (int) month
     * (int) year
     * (float) latitude_degree
     * (float) longitude_degree …
Run Code Online (Sandbox Code Playgroud)

php trigonometry date-sunrise

5
推荐指数
0
解决办法
1036
查看次数

CLLocationmanager:节省电池

我的新"正在进行的应用程序"使用CLLocationManager的实例用于多种目的.为了使应用程序尽可能对电池友好,应仅在需要时激活位置服务,并在数据刷新完成后立即停用.出于我的目的,仅在10秒内获取一次位置数据就足够了.(尚未确定确切的间隔长度).

我的问题是,"关闭位置服务"的电池效率最高的方法是什么?仅使用"stopUpdatingLocation"方法并将CLLocationManager本身保留在内存中是否足够,或者我是否需要释放整个实例,并在下次刷新之前分配一个新实例?

iphone cocoa-touch ios

4
推荐指数
1
解决办法
3479
查看次数

标签 统计

cocoa-touch ×1

date-sunrise ×1

ios ×1

iphone ×1

php ×1

trigonometry ×1