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.
5
votes
1answer
38 views
Formatting seconds as hours:minutes:seconds
This is basically my school homework and I want to know what to improve, and what not to do.
The homework basically is this:
You will get a input in seconds, which is supposed to be shown as H:MM:SS ...
4
votes
1answer
30 views
Efficient date-based lookup function in R
Right now this function takes an excessively long time to run, please let me know how to make it more efficient.
lunarCal is 144x7 and the ...
1
vote
1answer
60 views
Ruby class to model (pre)historical Dates with (im)precision
I am relatively new to Ruby, having worked with Rails for about 8 months.
For fun and my own education, I have written a Ruby gem (no Rails) that models dates with a precision (second, minute, hour, ...
3
votes
2answers
38 views
Finding maxDate for each entity
I have a table with (CompanyNumber, File_Date, [various financial results])
I wanted to get only the most recent set of accounts for each company.
After various ...
4
votes
2answers
66 views
Simple C# application that transfers new files (modified in the last 24 hours) from one directory to another
I'm new to C#, so I'm eager for any and all criticism/advice.
...
3
votes
0answers
32 views
Calculate attendance compliance based on attendance record
This is part of a larger working system which I'm now trying to clean up. In the interests of making the system more test-able I'm splitting up the functions which can be split, but this 100-line ...
1
vote
0answers
37 views
Comparing datetime ranges in Python [closed]
I have a set of datetimes that defines times for running a particular job. I'm wondering what is the best way to compare them.
Example:
I have a list:
...
3
votes
1answer
29 views
Python get UTC offset for when only naive date time objects are available
The function below is designed to return a UTC offset string, in the form used widely by timestamps, of the user's current time for when only naive date time objects are available (no time zone ...
1
vote
1answer
35 views
Sort by year and day descending, yet time ascending
I recently discovered a hugely inefficient portion of code in my program, and have gone about rewriting it. I am however, not quite sure if the rewritten program actually does exactly what I want, due ...
1
vote
1answer
31 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
62 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 ...
5
votes
1answer
42 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
44 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
51 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
66 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
47 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
42 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
29 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
86 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
56 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
71 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
31 views
2
votes
0answers
31 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
13 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
5
votes
2answers
64 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
89 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
235 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
33 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
143 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
55 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
60 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
71 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 ...
29
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
41 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
102 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
46 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
52 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
82 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
79 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 ...
5
votes
3answers
223 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
134 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
61 views
2
votes
3answers
470 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
150 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
76 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
57 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.
...