momentjs不断收到以下错误moment.js:弃用警告:提供的值不在公认的RFC2822或ISO中

时间:2017-05-05 14:57:33

标签: laravel fullcalendar momentjs

我正在尝试将maddhatter laravel-fullcalendar整合到一个laravel应用程序中,我的日历可以在大多数浏览器上运行但是在Internet Exprorer上失败,当我进行检查时,我得到了弃用警告。

我的数组看起来像这样:

   /* C program for Merge Sort */
#include<stdlib.h>
#include<stdio.h>
#include <pthread.h>
#include <time.h>

#define N 100

// Merges two subarrays of arr[].
// First subarray is arr[l..m]
// Second subarray is arr[m+1..r]
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    /* create temp arrays */
    int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for (j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray
    j = 0; // Initial index of second subarray
    k = l; // Initial index of merged subarray
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there
       are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there
       are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the
   sub-array of arr to be sorted */
void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = l+(r-l)/2;

        // Sort first and second halves
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);

        merge(arr, l, m, r);
    }
}

void* mergeSort2(void* args)
{

    int* newArgs = (int*)args;
    int l = newArgs[1];
    int r = newArgs[2];

    pthread_t thread1 , thread2;
    int ans1, ans2;

    if (l < r)
    {
        // Same as (l+r)/2, but avoids overflow for
        // large l and h
        int m = (r+l)/2;
        int newArgs1[3] = {newArgs[0], l, m};
        int newArgs2[3] = {newArgs[0], m+1, r};
        ans1 = pthread_create ( &thread1 , NULL , mergeSort2 ,(void*)newArgs1);
        ans1 = pthread_create ( &thread2 , NULL , mergeSort2 ,(void*)newArgs2);
        pthread_join(thread1,NULL);     
        pthread_join(thread2,NULL);

        merge(newArgs[0], l, m, r);

    }

}

/* UTILITY FUNCTIONS */
/* Function to print an array */
void printArray(int A[], int size)
{
    int i;
    for (i=0; i < size; i++)
        printf("%d ", A[i]);
    printf("\n");
}

static void print_timestamp(void)
{
    time_t now = time(0);
    struct tm *utc = gmtime(&now);
    char iso8601[32];
    strftime(iso8601, sizeof(iso8601), "%Y-%m-%d  %H:%M:%S", utc);
    printf("%s\n", iso8601);
}

/* Driver program to test above functions */
int main()
{
    int min = -1000, max = 1000;
    int arr[10], arr2[10], arr3[10];
    int i,r;
    int arr_size = sizeof(arr)/sizeof(arr[0]);
    int id1,id2;
    int args[3] ={arr3, 0, arr_size - 1};
     struct timeval tvalBefore, tvalAfter;
     struct timeval tvalBefore1, tvalAfter1;
    //Threads init
    pthread_t thread1;
    int ans1;

    srand(time(NULL));

    for( i = 0; i < arr_size; i++){
        r = rand() % (max - min + 1);
        arr[i] = r;
        arr2[i] = r;
        arr3[i] = r;
    }
    //printf("Before: \n");

    if((id1 = fork()) == 0)
    {
     gettimeofday (&tvalBefore, NULL);
    //Operation to do
        printf("Child1: \n");
        mergeSort(arr2, 0, arr_size - 1);
        printArray(arr2, arr_size);
        print_timestamp();
    gettimeofday (&tvalAfter, NULL);

    // Changed format to long int (%ld), changed time calculation

    printf("Time in microseconds for sorting CHILD 1: %ld microseconds\n",
            ((tvalAfter.tv_sec - tvalBefore.tv_sec)*1000000L
           +tvalAfter.tv_usec) - tvalBefore.tv_usec
          ); // Added semicolon
    }

    else if((id2 = fork()) == 0)
    {

        printf("Child2: \n");
        //Start Timer
        gettimeofday (&tvalBefore1, NULL);
        //Operation to do
        ans1 = pthread_create ( &thread1 , NULL , mergeSort2 ,(void*)args);
        pthread_join ( thread1 , NULL ) ;

        print_timestamp();
        gettimeofday (&tvalAfter1, NULL);
        // Changed format to long int (%ld), changed time calculation

         printf("Time in microseconds for sorting CHILD 2: %ld microseconds\n",
            ((tvalAfter1.tv_sec - tvalBefore1.tv_sec)*1000000L
           +tvalAfter1.tv_usec) - tvalBefore1.tv_usec
          ); // Added semicolon
    }

    else{
        wait();
        wait();
         gettimeofday (&tvalBefore, NULL);
        //Operation to do
        printf("Given array is \n");
        printArray(arr, arr_size);
        printf("Father:\n");
        mergeSort(arr, 0, arr_size - 1);
        printArray(arr, arr_size);
        print_timestamp();

        gettimeofday (&tvalAfter, NULL);

    // Changed format to long int (%ld), changed time calculation

    printf("Time in microseconds for sorting Father: %ld microseconds\n",
            ((tvalAfter.tv_sec - tvalBefore.tv_sec)*1000000L
           +tvalAfter.tv_usec) - tvalBefore.tv_usec
          ); // Added semicolon
    }
    return 0;
}

不确定我做错了什么。

完整错误看起来像这样

$('#calendar-wean15RN').fullCalendar({
  "header":{
     "left":"prev,next today",
     "center":"title",
     "right":"month,agendaWeek,agendaDay"
  },
  "eventLimit":true,
  "defaultDate":"Apr 2017",
  "eventColor":"#3c8dbc !important",
  "eventBackgroundColor":"#3c8dbc !important",
  "eventBorderColor":"#3c8dbc",
  "eventTextColor":"#fff !important",
  "events":[{
    "id":"1557",
    "title":"xxx \nHrs worked:6.00",
    "allDay":"true",
    "start":"2017-04-03T09:00:00+00:00",
    "end":"2017-04-03T15:00:00+00:00",
    "url":"\/timesheet\/1557\/edit"
  }]
}

2 个答案:

答案 0 :(得分:0)

正如它在这里所说: https://fullcalendar.io/docs/current_date/defaultDate/ defaultDate也应该是ISO8601日期字符串。

$('#calendar-wean15RN').fullCalendar(
    {"header":{"left":"prev,next today","center":"title","right":"month,agendaWeek,agendaDay"},"eventLimit":true,"defaultDate":"2017-04-03T09:00:00+00:00","eventColor":"#3c8dbc !important","eventBackgroundColor":"#3c8dbc !important","eventBorderColor":"#3c8dbc","eventTextColor":"#fff !important","events":[{"id":"1557","title":"xxx \nHrs worked:6.00","allDay":"true","start":"2017-04-03T09:00:00+00:00","end":"2017-04-03T15:00:00+00:00","url":"\/timesheet\/1557\/edit"}]
}

答案 1 :(得分:0)

"defaultDate":"Apr 2017"更改为"defaultDate":moment("Apr 2017", "MMM YYYY")

FullCalendar文档声明defaultDate的类型是Moment。

警告说:提供的值("Apr 2017")不是公认的RFC2822或ISO格式;所以你必须使用moment(String, String)解析函数。