How do time.js handle leap seconds?

I need a way to always add the whole minute to the timestamp, even if the minute lasts 61 seconds due to the planned second of the jump. Does anyone know if a moment().add(1, 'minute')minute adds , regardless of the seconds of the jump? Or does he always add sixty seconds?

I found how it handles the addition during daylight saving time and a leap year, but nothing happens in seconds of the jump.

To give some insight into why this is important:

I need to create a CSV file with a bunch of minute sensor data for various sensors, formatted as:

time,sensor1,sensor2
1491329921800,20,21
1491329981800,22,21

My data is saved along with a timestamp for the start of the hour, and then an array of sixty data points for an hour.

{
    timestamp: Date(2017,2,24,12,0,0),
    temperature: [20, 22, 23, ... <60 elements total>]
}

timestamp'd, ( , - , ).

, . , CSV; ; , .

, CSV :

    var date = moment(startDate);
    var end = endDate.getTime();

    var timestamps = [];

    while(date.valueOf() < end) {
        timestamps.push(date.valueOf());
        date.add(1, 'minute')
    }
    timestamps.push(date.valueOf());

, . , date.add(1, 'minute') date.add(1, 'minute').startOf('minute'), , , .

+4

Source: https://habr.com/ru/post/1674037/


All Articles