Questions tagged [datetime]

DateTime objects in many programming languages describe an instant in time, expressed as a date and time of day. Use on questions about reviewing code involving date/time logic.

Filter by
Sorted by
Tagged with
2
votes
1answer
22 views

Input any time, output timezones that are currently that time

I made a program that will take in a time and a weekday, and return which parts of the world are at times closest to the one specified. Part of the program focuses on extracting a date and country out ...
1
vote
1answer
26 views

JavaScript date format string to php date format string convert

Please find the following scenario, I've dynamic JS date format string from API but I am looking for the best way to convert the format that accepts in PHP date format. For now, I wrote it my own way ...
2
votes
1answer
40 views

JavaScript function for the get the formatted date of tomorrow

I need a JavaScript-function which always computes the date of the next day. Then returns the date as a string, formatted in the way: dd.mm.yyyy I wrote this code: ...
2
votes
0answers
60 views

Creating calendar - Speeding up PHP script

I'm working on a calendar for my office. Every people has his own column and there is a line for every day. There are some periodic date, where, for example, given people have to be working on the ...
9
votes
4answers
573 views

Calculating parking fees, given start and end timestamps

Since I have just started Javascript, I am trying to solve a few problems and improve myself. I encountered such a question. I tried to do everything step by step from the question, but I do not think ...
2
votes
1answer
35 views

PowerShell - calculate occurences of Friday the 13th between (including) two given years with builtin and without builtin

It's me again, talented programming beginner fast-learner, so I have overcomed yet another self-imposed programming challenge, I have developped two algorithms to calculate occurrences of Friday the ...
1
vote
0answers
47 views

PowerShell - Calculating date difference between two given dates in days without builtin and with builtin

The title says it all, I have written two scripts to calculate dates to test my abilities in programming, one from scratch, without [DateTime], New-TimeSpan and even [math]::Ceiling, and it's really ...
3
votes
1answer
35 views

Calculating difference between cached period and requested

There is a remote resource containing datasets arranged by time, data is static and doesnt change. Whenever we are going to fetch anything from there we will be saving it in our cache. User might ...
2
votes
1answer
54 views

Countdown click in JavaScript

I did a small countdown clock challenge in JavaScript. Please review it, thanks. ...
3
votes
2answers
65 views

Calculate age given the birth date in the format YYYYMMDD

Here is method to calculate age given the birth date in the format YYYYMMDD. ...
2
votes
1answer
90 views

DateTime range splitting algorithm

I have the algorithm which splits DateTime range into multiple ranges based on night time range. For example: Night start: 22:00, Night end: 06:00 Start time: 2020-10-26 21:00:00 End time: 2020-10-27 ...
2
votes
2answers
318 views

Checking if the access token is valid or expired

Basically, the server gives me a token object. I am planning to check the token on the client if it is expired/valid before ...
2
votes
2answers
139 views

Date Detection with Python RegEx

its a practice project from "Automate the Boring stuff with Python" book. i am an intermediate level Python programmer and i tried to solve this problem with less code as possible. This code ...
3
votes
0answers
51 views

Calculate age from birthday in C#

For a project I'm working on, I need to calculate the age of users based on their birthday (which is a DateTime object). with a few requirements: the output must be in french (the entire project is ...
3
votes
1answer
50 views

ways to code for better speed of processing date comparisions / slicing in python

I wrote the below code to convert a long data frame containing start and end date event spans into a daily df with rows for each day: output: ...
-2
votes
1answer
43 views

what is the best practice concerning opening CSV files in python [closed]

I am looking for the best way to save regular data from a series of sensors to a CSV file. the program will be reading every sensor once a minute 24/7 and needs to report the results to a CSV file ...
2
votes
1answer
43 views

Using datetime to obtain the time of the next lecture

Often before the lecture starts, and occasionally in the break I like to display a timer with a countdown until the lectures starts/ resumes while playing some lofi-hip hop in the background. While ...
6
votes
4answers
1k views

Convert minutes portion of time to decimal

I am making an hours calculator app. It takes a start time, end time and time taken for lunch. For the start and end time it takes a four-digit hh:mm time. For example: 10:20. I have made a function ...
3
votes
1answer
58 views

Does this R code look ok to expand out to other sites?

I'm after some constructive criticism on my code and maybe some ways to simplify before I expand it to include other sites. I am new to R and coding and have been working on this problem for weeks now....
3
votes
2answers
214 views

Javascript check if server time is greater than or less than 9am EST

I offer same day shipping if the user places an order before 9AM ET. If they place the order after 9AM, same day shipping is unavailable. My server is using UTC time so I need to check if the time is ...
4
votes
1answer
24 views

Creating formatted “[time] [unit] ago” messages from a seconds value

I have this function which calculates how many seconds, mins, hours etc ago a specific time string was. However, the way I have done it consists of a massive if statement block, and it goes through ...
1
vote
1answer
33 views

Check that elements in list follow a specified date-format schema and are not null/na/nan [closed]

I'm practicing some data-analysis and I'm currently checking the integrity of my data. The elements that do not follow my date-schema, should be funneled to a new separate list so I can work on ...
5
votes
2answers
314 views

Removing points from slow riders

I have a CSV like the following. ...
1
vote
1answer
67 views

Working out how many hours worked after a certain time

I am working on some custom rules in a time managment system and need to know how many hours in a shift have been before a certain time (19:00pm) and how many hours after. Shifts can start in the ...
4
votes
1answer
56 views

Apply additions on a base array based on date ranges

please roast my code, I hope this is the good place to look for some advice on where I can improve. Problem definition: Apply modifications on values depending on date ranges. Data: Base array - ...
2
votes
0answers
41 views

Fastest conversion of ISO 8601 string into javascript Date object

On StackOverflow I got a great answer to a question I had about creating a Date object from an ISO 8601 string with the ability to reposition into local time. From there I wanted to see if I could ...
-2
votes
2answers
76 views

Time diff in days [closed]

I have the following snippet: ...
2
votes
1answer
75 views

Parse org-mode clocktable CSVs into time sheets

For my student job, I have been logging work times with the org-mode in emacs for quite some time. Now since I can only work from remote, I figured it would be nice ...
2
votes
0answers
40 views

Generate ISO 8601 Duration String from Two Date Objects

I've written a function which should generate an ISO 8601 duration string, given two Dates as input. ...
0
votes
0answers
56 views

Code for creating a dialog for choosing a date

I have code that creates an AlertDialog to select a date by a user. I ran into a problem that this code began to take up a lot of space. Could you offer ideas on how to shorten this code / put it into ...
4
votes
1answer
44 views

Moving all .xlsx files from the last five days (but not today)

My code works, but it looks very bad. I need to move .xlsx files from the previous days from one folder to another, but I should'nt move the files with today's ...
1
vote
0answers
21 views

Transforming NodaTime ZoneIntervals, version 2

Version 1 may be found here. I have implemented the suggestions by Jon Skeet, plus some of my own. Key differences between versions: ZonedDateRange class is now immutable. LocalDate variables no ...
14
votes
3answers
2k views

Compute the next occurrence of Friday the 13th

How can I get the date of the next occurrence of Friday the 13th? Below is my attempt. It returns the correct results. I think there must be a better way of writing this without checking ...
4
votes
1answer
84 views

Transforming NodaTime ZoneIntervals

Version 2 may be found here. The company I work for has customers around the globe. I work with a time-series database that contains manufacturing process data for each customer site. I was asked ...
4
votes
3answers
85 views

Seconds into readable time information

I had an exercise to solve, written in German. I try to translate it: Write a program that takes an amount of seconds. The program than has to output the number of years, days, hours and seconds. ...
6
votes
2answers
80 views

Combining GPS and vehicle data using for loops and if statements to summarise the distance run under various conditions, much like a excel SUMIF

This is a follow-up to previous post, code is significantly better thanks to comments. The problem is that now it takes 0.25 seconds to iterate 1 row of VehicleEvents through 95000 rows of GPS ...
12
votes
6answers
6k views

Python Code for List of Month Names starting with current month

I am looking for a cleaner, more pythonic way to get a list of the name of the months starting with the current month and ending 12 months later. For example, it's December so my list should be <...
1
vote
0answers
74 views

Running some code every day at certain times

I am currently developing a windows service in C# which is supposed to run a data import every day at configurable times. For this purpose I have created a class "ExecutionTime" which contains the ...
1
vote
2answers
73 views

Date Class, implemented

I'm implementing this date class based on <ctime> I'll appreciate your comments, critics and advice. Please review, thank you!. Date.h ...
9
votes
1answer
1k views

C function to check the validity of a date in DD.MM.YYYY format [closed]

I was tasked with writing a function, that checks whether a date is valid in the following format: DD.MM.YYYY. Here's what I wrote: ...
7
votes
1answer
236 views

Interpret a date from a string of digits

I developed a function that, from a given sequence of digits, extracts the date and reformat it. This is the code: ...
4
votes
2answers
72 views

Simple timestamping filter in C

I wrote a simple timestamping filter that prepends each line with the UNIX timestamp in nanosecond precision as returned by clock_gettime, as well as the difference to the previous timestamp. ...
0
votes
2answers
146 views

Project Euler problem #19: counting months that began on Sundays

You are given the following information, but you may prefer to do some research for yourself. 1 Jan 1900 was a Monday. Thirty days has September, April, June and November. All the rest ...
5
votes
3answers
384 views

Python process tracklist, get cumulative timestamp of each track

The code below parses a tracklist (sample input below) and generates a six-member tuple, including cumulative timestamps in mm:ss. (sample output at bottom). ...
11
votes
2answers
1k views

Converting time in number of minutes past midnight to HH:MM format

This program is a clock that only displays minutes passed since midnight. This program is supposed to be really simple but because of some "aesthetic bug", I wrote quite a lot if-else statements that ...
4
votes
1answer
302 views

Cython functions for generating NumPy date ranges

I have rewritten my python code in cython in order to speed up it quite a bit. However after checking the code in jupyter it seems that part of it is still compiled as python code, therefore its not ...
3
votes
1answer
58 views

List of dates with special formatting

I have a code that calls many times a function returning a list of the dates between two dates formatted as ('0001-01-01 00:01:00'),('0001-01-02 00:01:00'), ... The current solution is: ...
3
votes
1answer
40 views

How to properly get values from multidimensional object

Output should be an object ({cal: val}), with soonest possible time throughout all calendars recommended times from the data. My question is: is this approach over complicated and if so, what should ...
3
votes
1answer
140 views

Daily SQL job to delete records older than 24 hours

Below is a delete job to delete 1M+ records daily and takes 13 hours to complete and sometimes more than that. I need to optimize this. The table tblcalldatastore is being inserted 24*7 through a ...
3
votes
1answer
89 views

Date format function in JavaScript

How can I improve the date format function. I have written in javascript (ES5/ES6)? This code is just a part of an exercise. ...

1
2 3 4 5
20