小编Col*_*ner的帖子

Laravel 5.3 - Carbon Date - UTC 偏移量获取时区名称

我正在尝试使用 Carbon 从 Laravel 5.3 中的 UTC 偏移量获取时区名称。下面列出的代码任何帮助将不胜感激。

/* current code iteration */
$utcOffset = -5;
$timezone = Carbon::now($utcOffset)->timezone->getName();
echo $timezone;
// Result: -05:00
// Expected Result: EST

/* tried code */
$timezone = Carbon::now($utcOffset)->tzName;
// Result: -05:00

/* What I used prior to Carbon */
$timezone = timezone_name_from_abbr(null, $utcOffset * 3600, TRUE);
$dateTime = new DateTime();
$dateTime->setTimeZone(new DateTimeZone($timezone));
$timezone = $dateTime->format('T');'
Run Code Online (Sandbox Code Playgroud)

我缺少什么?我感觉很傻..

php datetime laravel php-carbon

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

找不到 /root/.composer/vendor/bin/laravel: 没有那个文件或目录

我已经使用 PHP 5.6.27 在 Centos 7 virtualbox 上安装了 composer。我将展示我使用过的命令以及我现在遇到的问题。我应该首先说所有这些命令都适用于以前的安装。

好的,所以对于初学者来说,这里是我用来安装作曲家的。

curl -sS https://getcomposer.org/installer | php
Run Code Online (Sandbox Code Playgroud)

其次是

mv composer.phar /usr/local/bin/composer
Run Code Online (Sandbox Code Playgroud)

现在我正在尝试通过下面列出的命令安装 laravel。

composer global require "acacha/adminlte-laravel-installer=~3.0"
Run Code Online (Sandbox Code Playgroud)

到目前为止,上面列出的所有命令都已成功运行。

现在这是当前的问题。当我尝试运行以下命令时,出现错误。

laravel new laravel-with-admin-lte
-bash: /root/.composer/vendor/bin/laravel: No such file or directory.
Run Code Online (Sandbox Code Playgroud)

我已经针对这条消息尝试了一整套补救措施,但它找不到 .composer 目录。谁能告诉我正确的 .composer 目录在哪里,以及如何修改它以使其看起来正确的位置来完成此安装?

我感谢您提供给我的任何解决方案。我已经连续两天为此苦苦挣扎,并且在阳光下搜索了一切。希望这里有人有一个类似的解决方案,具有有效的分辨率。

virtualbox centos laravel composer-php adminlte

3
推荐指数
2
解决办法
6777
查看次数

C#SelectVoice不会在Windows应用程序中更改,但会在控制台中更改

因此,我试图在System.Speech.Synthesis库的C#中更改声音。当我在控制台模式下尝试代码时,它将为我工作。但是,当我在Windows应用程序上工作时,它不会更改声音,同时不会出错。这是Windows应用程序的代码,该代码可用于语音更改之外。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Speech.Synthesis;
using System.Speech.Recognition;

namespace JarvisRev1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.button1.Click += new EventHandler(button1_Click);
            this.button2.Click += new EventHandler(button2_Click);
            this.button3.Click += new EventHandler(button3_Click);

            foreach (InstalledVoice voice in sSynth.GetInstalledVoices())
            {
                cbVoice.Items.Add(voice.VoiceInfo.Name);
            }
        }

        SpeechSynthesizer sSynth = new SpeechSynthesizer();
        PromptBuilder pBuilder = new PromptBuilder();
        SpeechRecognitionEngine sRecognize = new SpeechRecognitionEngine();


        private void button1_Click(object sender, EventArgs e)
        { …
Run Code Online (Sandbox Code Playgroud)

c# voice system speech selector

2
推荐指数
1
解决办法
1918
查看次数

Timer.scheduledTimer 未触发

我正在尝试计算车辆在两个检查站之间经过的时间。我已经设置了以下计时器来实现这一点。

func startTimer() {
    if hasStarted == true && timerStarted == false {
        print("Timing started!")
        gameTimer = Timer.scheduledTimer(timeInterval: 0.001, target: self, selector: (#selector(activeTiming)), userInfo: nil, repeats: true)
        timerStarted = true
    }
}

@objc func activeTiming() {
    print("Active timing block")
    if(hasFinished == false) {
        gameTime = gameTime + 0.001
        print("Add time succeeded")
    } else {
        gameTimer?.invalidate()
    }
}
Run Code Online (Sandbox Code Playgroud)

预期输出如下:

Timing started!
Active timing block
Add time succeeded
Add time succeeded ... etc
Run Code Online (Sandbox Code Playgroud)

实际输出:

Timing started!
Run Code Online (Sandbox Code Playgroud)

所以看起来 startTimer 被正确调用,但计时器没有触发 activeTiming 代码块。任何建议都会非常有帮助。提前谢谢你的帮助。

nstimer scenekit swift

2
推荐指数
3
解决办法
3214
查看次数