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

3
votes
1answer
60 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
64 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
119 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 ...
-1
votes
0answers
24 views

Custom deserialization of datetime in Sling

This is my solution to my question on Stackoverflow Custom deserialization of datetime in Sling, which turned out to be a duplicate. I have some json I'd like to deserialise, which has datetimes in a ...
2
votes
3answers
115 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
47 views

Finding the date 18 years ago

Here's what I have: ...
2
votes
3answers
439 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
86 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
50 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
43 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
110 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
56 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 ...
1
vote
2answers
48 views

Converting events in an agenda to textual format

Here is a serializer and my concern is to make convert_to_internal function more pythanic, efficient and ideally more functional. Maybe I could get rid of three nested loops also. ...
3
votes
2answers
23 views

Partitioning comments by date

I have a list of Comment objects comments. Each Comment has several properties, one of which ...
-3
votes
2answers
32 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
19 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
75 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
31 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" ...
1
vote
1answer
46 views

Rake task to send users a reminder to post with conditions

I am implementing a feature that reminds users to make a post via email if the user has set daily reminders to true he has not posted yet today and if the current hour matches when he would like ...
2
votes
1answer
49 views

“Can a list of meetings all be scheduled in a conference room?”

I was given this question at an interview for a position I just got rejected by, so looking to improve and see what better answers there are! ...
3
votes
1answer
48 views

Stored procedure to classify policies by sales date

Currently this is the store procedure I am working on, it is working according to some testing that was done. I feel that it could be improved though, could use some optimization, feedback or ...
2
votes
1answer
65 views

Generating calendar months for a datepicker

I got a problem I'm finding pretty hard to solve. I'm trying to generate calendar months for a datepicker but at only 12 months I see a perf of around ~4-7ms. This doesn't sound like a problem but it ...
5
votes
1answer
128 views

Create array of date pairs for next 10 days

I wrote the below function which successfully creates pairs of dates in the format I need. However, I'm fairly new to Python and feel there must be a way to make this easier to read. Can this code be ...
5
votes
1answer
107 views

Is date 18+ years old?

Considering that: the passed parameters are all numbers the passed date is a valid date It should return: true if the date is 18 or more years old ...
0
votes
1answer
47 views

Four jQuery date time pickers

I'm using the Jquery date time picker link here In the four methods below I am initializing the DT pickers but they are all pretty similar except for the ID in the ...
3
votes
2answers
68 views

Convert a start and end date chosen by a user to epoch

This method allows the user to choose a start and end date in human readable form, then convert it to epoch. The method will return a array of longs composed by the ...
1
vote
1answer
38 views

Getting last and this monday as Unix timestamp in JavaScript

This is how I achieved it: ...
3
votes
0answers
79 views

Todo list with calendar

The app is a todo list with a three-day calendar. Users can add and remove lists and it's all stored in local storage. My aim was to use vanilla JS but I did use jQuery for the date picker. I'm just ...
5
votes
2answers
183 views

Custom sorting of dates

I have implemented a class which implements a list of my custom DateObj. I have sorted the list in a peculiar manner based on the current month. I achieved my ...
7
votes
2answers
592 views

Simple DateTime abstraction

Some of my tests require that I need to test the date time results (like time stamps etc.). In order to be able to test the date time string I created a simple ...
1
vote
0answers
28 views

Calculation of duration between two timestamps in different rows

In my sample data table below, all datatypes are varchar(255). ...
5
votes
4answers
404 views

Comparing dates (without the time part) in Java

In my current project, I have to deal a lot with dates, especially checking if the date entered by user is today, or max one year from today etc. As I find the datetime API of Java7 (which I ...
6
votes
1answer
72 views

JavaScript DateTime library

To keep it succinct, I created a simple way to input dates and times into an input box without worrying about formatting. As an alternative to date time pickers, dropdowns and all the other various ...
6
votes
2answers
82 views

Hours:Minutes Addition

I wrote this simple page to help at work, and as an exercise to get more familiar with JavaScript. I'm especially interested in help with style and structure - is this "standard"? I know the input ...
7
votes
2answers
50 views

Execute every Monday that is not the Monday following last Saturday in month

I think the following is good but wondering if it can be simplified or improved. My condition for code execution is the following: It is a Monday AND It is not the Monday following the last Saturday ...
6
votes
3answers
181 views

Ordering an un-ambiguous scrambled date

A date is un-ambiguous when each number may be decided to be day or month or year given the range limitation of these numbers. For example \$14\$ cannot be a month number \$2008\$ cannot be ...
14
votes
4answers
965 views

Enter year, date, and month in any order, I'll organize it

I would like some advice on how I could make it less repetitive and use more functions and classes. ...
6
votes
2answers
30 views

Checking and converting [[HH:]MM:]SS input format

I would like to use the following routine in my job submission bash script which expects the allowed walltime in the format [[HH:]MM:]SS. (Brackets indicating ...
11
votes
4answers
478 views

Function to format the local time

This is a statement that I use a lot in my code base: (LocalDateTime.now()).format(DateTimeFormatter.ofPattern("ssmmHHddMMMuu")) Should I create a static method ...
4
votes
1answer
524 views

Deleting millions of rows from a MSSQL server table

This SQL query took 38 minutes to delete just 10K of rows. How can I optimize it? Index already exists for CREATEDATE from ...
4
votes
3answers
83 views

NTP Clock on a Raspberry Pi

I've been tinkering around with making a fancy clock on a Raspberry Pi B. This little application will sync the Pi's time with an NTP server, then display it using ...
4
votes
0answers
57 views

Multi-function clock GUI

I was sitting in my bedroom, looking at my Powers of 2 clock sitting next to my radio, under my analog clock on the wall, and wondered to myself: "Why have all these different clocks when I can have ...
6
votes
1answer
180 views

Combining two clock tick vectors with NumPy

I have two long (7683200 length) 1D arrays corresponding to two clock cycles, that I wish to combine into single 1D array. The clock_ticks_fine cycles between ...
4
votes
1answer
30 views

Selecting time metadata off a calendar table

I have a report on SSRS (that's SQL Server Reporting Services) that I need to be able to parameterize so that it can run for.. Yesterday (scheduled every morning) The week that just elapsed ...
4
votes
1answer
96 views

Seven-segment display GUI

I am building a GUI to display a digital clock face (four seven segment displays), and I have a selector to switch between 12/24-hour formats. I have working code to show both formats, but it is ...
3
votes
2answers
44 views

Return the first number found greater than the provided input number (13 digits)

This script converts the numbers to be at least 13 characters long (for UNIX_MS strings). For use with timestamps, I'm having issues with it being very slow. I wanted an alternative to grepping for ...
3
votes
0answers
44 views

A version of the Pebble Big Time watch face that also displays the date

I'm seeking style pointers, bugs, memory leaks, incorrect usage etc. ...
5
votes
3answers
268 views

Sorting a list based on date and time

I have a class that is used to basically store samples from data being read from a system. Within that class is a property that I use to store the date and time of that sample: ...
4
votes
3answers
393 views

12 hours to 24 hours conversion function

I have made a time format converter which converts 12 hour format to 24 hour format. My convert_to_24() takes a string in format of ...