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.

learn more… | top users | synonyms

1
vote
1answer
18 views

Building a 2D array “month view” for a given date

I am working on a calendar widget for a project. For any given date, I need to build a 2D array representing the "Month" that the date falls in, where the rows represent weeks in the month and the ...
5
votes
1answer
61 views

Merging trips to the same location with overlapping dates

I have a SQLite database that only contains the holidays for 1 user. I have a new Trip object (newTrip) that has a ...
4
votes
1answer
35 views

Generate dyamic 'week of' date range

I was in need of a method to dynamically generate a week range, so that the view reads something like "Week of May 16 - 22" and updates automatically. Here's the helper method I came up with, but I'm ...
1
vote
2answers
40 views

AM/PM to 24 hour time conversion

I recently joined the website www.hackerrank.com for programming challenges, and one of them was a time conversion from 12 hour to 24 hour. Rather than using the ...
3
votes
1answer
47 views

Spring controller code to group information by date

I'm using the Spring Framework in my web application and I'm curious as to whether my controller implementations are good or not. I've used many Hashmaps to make a object that serves my purpose for ...
2
votes
2answers
61 views

Calculate daily average for selected period in PHP

I would like to calculate the average for the same days (e.g. Monday, Tuesday, etc) in a selected period: ...
3
votes
1answer
44 views

Splitting a date-range - can it be improved somehow?

I've created a method to split a date range into a collection of date-arrays. These arrays consist of two timestamps. Example: ...
2
votes
3answers
41 views

Validating five date fields in Angular.js

So I have following piece of code which basically validates five date fields in angular service. But the catch is that there may be one to five field(s) visible on the screen based on some other ...
2
votes
1answer
21 views

Printing the start and end dates of the most recent eight weeks

I have a table with columns dated by week that changes dynamically each day. Currently, I am using the following php code to get the proper dates for the past eight weeks: ...
6
votes
2answers
68 views

Populating an array with times with half hour interval between them

So for example, getTimes("12:00", "15:30"); should return: ["12:00", "12:30", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30"] The input parameters are always ...
4
votes
1answer
55 views

12/24h Time format converter

I am really new at this and I was wondering if there is a more efficient way of writing this code, which converts time format to 12-hour from 24-hour format, and vice-versa. For example ...
5
votes
1answer
52 views

Let's have a meetup

Problem statement: Calculate the date of meetups. Typically meetups happen on the same day of the week. Examples are the first Monday the third Tuesday the Wednesteenth the ...
4
votes
1answer
66 views

JavaScript calendar widget

I'd like to know how I can refactor my JS code for usability. Currently my JavaScript uses some HTML to build out a simple calendar with the following functionality: a. opens into the current month ...
1
vote
2answers
28 views
1
vote
0answers
25 views

Few DatePickers and TimePickers in Android activity

I'm developing an Android activity which asks user to enter start and end dates and times in order to know a certain period of time. After picking start date, user picks start time, and then he/she ...
1
vote
0answers
12 views

Table Trigger to update date columns

I've created the following trigger to force two columns (date_edited and date_deleted) to have the ...
7
votes
7answers
1k views

Printing future leap years

My code prints the next 20 leap years: ...
5
votes
2answers
61 views

Time manipulation for notification reminders

I'm new to programming, Stack Overflow and Code Review. I was encouraged to post this method here based on a question I posted on StackOverflow here. Let me know if you have tips for improving this ...
6
votes
3answers
87 views

Find the date for the nearest day of the week, in this case Fri & Sat

General objective: Find the date (day of the month) of the nearest specified day of the week and output. More specifically: Focusing on events which take place every Fri & Sat, want the page to ...
4
votes
4answers
221 views

Converting the DateTime to and from Unix epoch times

I'm currently working on a thing I needed this feature for. Essentially, these are two methods to convert DateTime objects to and from the Unix epoch time (two ...
0
votes
1answer
32 views

Convert MS SQL datetime to Oracle varchar(32) interval

I have a query against an MS SQL database that takes the resulting dataset and stores it in an Oracle database table which then gets joined to another Oracle table using the column ...
2
votes
0answers
19 views

Generating days in a specific range

I have a query in MSSQL, where I get a summary by days from a range in a table, and this is in union with other queries. This query is used to generate days in a specific range, then add the registry ...
5
votes
3answers
137 views

Getting the business day of the month

I'm working on figuring out what the current 'business' day of the month it is. For instance, if it's the 20th, but there are 3 weekends, it would be the 14th business day of the month. Is there a ...
3
votes
0answers
48 views

C++ time types and format conversions

I wrote a small header-only C++11 header for converting between various C++ time formats. Here's the code in question: ...
4
votes
2answers
57 views

Calculate the difference between current date and age from personal ID

The goal is to show message for users that are less 25 years old. The personal ID consists of 081010333333, where 08year, 10month, 10date. I made code and it's very messy. So the question is: how to ...
2
votes
1answer
64 views

RPi script to periodically collect data from Arduino through serial port

I'm not used to Python. The script opens serial communications with an Arduino unit and send commands to and receives information from the Arduino. It is intended to run indefinitely until the system ...
27
votes
5answers
3k views

Event scheduler in C

One of my university assignments asked us to create a program using struct in order to create a simple event scheduler. This program is for a single day only, not ...
2
votes
0answers
39 views

Weather Application - Reavling Module Pattern

I'm trying to practice and learn design patterns, and I decided to create a weather app using the revealing module pattern. How can I improve on this, and what mistakes did I make? Main.js ...
4
votes
1answer
86 views

Calendar made with tkinter

I made a calendar that displays text documents according to month. Thankfully it works, although I could really use some help how to make it more better looking and efficient. I'm new to programming ...
3
votes
1answer
16 views

SQL report of subscribers and their associated revenue

A user can have many subscriptions, and a subscription belongs to one plan. The plans table tells us a subscription's cost. Is the query below the correct one for ...
6
votes
1answer
44 views

Aligning out-of-sync subtitles

This is my 2nd program I wrote on my own, a pretty simple program consisting of two functions (those functions are not combined in any way yet though). The first function moves the display times of ...
3
votes
1answer
50 views

Find all instances of a given weekday in February for a given year

A friend of mine was practicing his programming skills with a textbook meant to prepare students for computer science exams. He asked for help with a specific task. The task is to capture user input ...
3
votes
1answer
81 views

Age Calculations (First Draft)

I found another user asking for an application to be written, it sounded simple enough and a good way to "work out" my C# "muscles" and try to get them into a better "shape". I really liked the idea ...
4
votes
3answers
78 views

Extracting sleep quality scores from periodic readings

How can I optimize the next function to work faster? The function must prepare a list to put in a CSV file. The list must contain values of average percentage of sleep per minute counted from ...
4
votes
2answers
176 views

Ruby method that returns an age from a date of birth

I have a method on my user model to calculate the user's age and return a human readable string. My user's can be between 1 month old and above so the returned string is different depending on if the ...
2
votes
3answers
133 views

Adding minutes to a time value in Ruby

I recently submitted a code-challenge for an interview according to the following guidelines: About Write a function or method that accepts two mandatory arguments and returns a result. ...
1
vote
1answer
60 views

Finding the date 18 years ago

Here's what I have: ...
2
votes
3answers
460 views

Creating an array with quarter hour times

There is no need for me to use 50 lines of code here, but how can I populate this array in a loop without using date/time methods. ...
1
vote
1answer
130 views

Check if the user is 18 years old (upto days)

This code is returning 'true' for any date which are later than Feb 24, 1998. ...
3
votes
1answer
70 views

Timestamp function with millisecond precision

I want to be able to print timestamps with milliseconds precision and time_t doesn't provide this. I also want the code to be portable, so operating specific ...
0
votes
2answers
54 views

Seconds -> Days, Hours, Minutes, and Seconds

This is just a simple function to convert seconds to days, hours, minutes and seconds for a larger app I'm going to be building. I'm just looking for thoughts on it. ...
1
vote
0answers
25 views
6
votes
2answers
144 views

Prompt user for DateTime

I'm working on a project where I have to prompt a user a enter several dates. This is the code I came up with for prompting the user for the day, month, and year. ...
6
votes
1answer
75 views

Day, month and year clone in to one with MomentJS

There are two methods I am using here for merging day, month and year. First one ...
2
votes
2answers
55 views

Converting events in an agenda to textual format

Here is a serializer. My concern is to make the convert_to_internal function more pythonic, efficient and ideally more functional. Maybe I could also get rid of ...
3
votes
2answers
26 views

Partitioning comments by date

I have a list of Comment objects comments. Each Comment has several properties, one of which ...
-3
votes
2answers
38 views

Display calendar using a loop

Desired output: Can I get an shorter version of this code? My instructor just wants me to figure it out my self. ...
0
votes
0answers
21 views

Validate if time is valid including tests

So, I'm working on a method to validate if given time(s) are valid. In most cases, the input comes from the user. I'm not exactly sure on a few points: Readability Integrity Performance I'm also ...
5
votes
2answers
90 views

Create generic HTML calendar

I maintain our organizations intranet page as an additional duty. One thing that every department in the organization likes to use is calendars -- upcoming events, training, etc. At first I was only ...
4
votes
1answer
37 views

Add WeekDays to Date

Will the below code work for adding Weekdays in all possible scenarios? eg, If I add 4 days to a "Thursday", the result should be next "Wednesday". Adding 1 day to a "Friday", "Saturday" or "Sunday" ...